Ariana
uh
Ariana
/warns Averager
Anonymous
Guys can we convert this code to O(n) instead if O(n^2)
Anonymous
https://ideone.com/7BBDwK
Ariana
the time complexity of a algorithm is fixed
Ariana
also what are you trying
Anonymous
Any data structures or anything else can we applied so that it reduced to O(n)
Ariana
huh
Ибраги́м
say that I wanted a GraphQL implementation in D
You know libs are made users, mostly, NOT people who design the language
Anonymous
Rose?
Mihail
?
Akshay
Anyone help me to do circular boundary setting using GPS coordinates Arduino program
klimi
/report
For....
🐰🐾 سمیه
I like u, u do like dark adventures.
You're my lantern 🏮 😊
Isaac
Hello freinds in my following codes ?
klimi
hi
Isaac
// helper.hpp #ifndef HELPER_HPP #define HELPER_HPP #include <vector> #include <functional> #include <numeric> #include <iostream> #include <vector> #include <iterator> #include <string> #include <iomanip> // GABARIT->sew(int) #include <sstream> #include <fstream> #include <stdexcept> #include <exception> #include <cstdio> // perror // #include <cstring> std::stderror(errno) #include "class/vertex.hpp" #define INFTY 99999 template <class T> using matrix = std::vector<std::vector<T>>; template <class T> using row = std::vector<T>; using std::string; namespace helper { typedef struct GraphInfos GraphInfos; bool isNumber(const std::string& s); template <class T> void displayMatrix( std::vector < std::vector <T> >); template <class T> void displayMatrix( std::vector <T>); GraphInfos readGraphInfos(int inFileNumber, bool isCostMatrix); matrix<double> multiply(matrix<double> inLeftMatrix, matrix<double> inRightMatrix); bool isConnected( matrix<double> inMatrix, int inNodeA, int inNodeB); bool existPath( matrix<double> inMatrix, int inNodeA, int inNodeB ); // void backend(); void frontend(); void toCostMatrix();// void toAdjacencyMatrix();// int indexOf(row< Vertex<string>*> vectorOfString, Vertex<string>* vertex); } // helper #endif
BinaryByter
🙄
Isaac
// main.cpp #include <iostream> #include "../include/helper.hpp" // #include "../in" using std::cout; using std::endl; using std::endl; int main(int argc, char const *argv[]) { if(argc < 3 || argc > 3 || helper::isNumber(argv[1]) != (true) || (argv[2] != "true" && argv[2] != "false")) { cout << "COMMAND_OPTION_ERROR: the command app command requires two options" << endl; } else if (helper::isNumber(argv[1])){ /* code */ } int choice = 0; // switch (choice) // { // case 1: // /* code */ // break; // // default: // break; // } // int choice return 0; }
Mihail
I'd much rather not see the helper.cpp tbh
Mihail
Pastebin it first
Isaac
Pastebin it first
How about I paste it here intead of use pastebin service ?
Isaac
Let me paste it first and send the paste bin link
Isaac
#include "../include/helper.hpp" #include "../include/class/vertex.hpp" #include <string> using std::cout; using std::endl; using std::string; using std::cout; using std::clog; using std::cin; using std::cerr; using std::vector; using std::fstream; using std::getline; using std::istringstream; using std::exception; using std::ostringstream; using std::ifstream; using std::to_string; using std::setw; struct helper::GraphInfos { std::string verticesString; // read as string matrix matrix<std::string> graphMatrix; bool isCostMatrix; }; template < class T > void helper::displayMatrix( std::vector <T> inRow){ for(auto const & val : inRow){ // gabarit 10 cout << setw(10); cout << val; } } template < class T > void helper::displayMatrix( matrix < T > inMatrix) { for(auto const & row : inMatrix){ for(auto const & val : row){ // gabarit 10 cout << setw(10); cout << val ; } cout << endl << endl; } cout << __func__ << " says " << " goodBuye " << endl; } // util bool helper::isNumber(const std::string& s) { std::string::const_iterator it = s.begin(); while (it != s.end() && isdigit(*it)) ++it; return !s.empty() && it == s.end(); } int helper::indexOf(row< Vertex<std::string>*> vectorOfString, Vertex<std::string>* vertex) { int outIndex = -1; int size = vectorOfString.size(); for(int i = 0; i < size; i++){ if(*vectorOfString.at(i) == *vertex){ outIndex = i; break; } } return outIndex; } matrix<double> helper::multiply(matrix<double> inLeftMatrix, matrix<double> inRightMatrix) { matrix<double> outMatrix; int size = inLeftMatrix.size(); double tmpSum = 0; for(int i = 0; i < size; i++) { row<double> tmpRow; for(int j = 0; j < size; j++, tmpSum = 0) { for(int k = 0; k < size; k++) tmpSum += inLeftMatrix[i][k]*inRightMatrix[k][j]; tmpRow.push_back((bool)tmpSum); } outMatrix.push_back(tmpRow); } return outMatrix; } // // This function check if two nodes are directly connected bool helper::isConnected( matrix<double> inMatrix, int inNodeA, int inNodeB) { return (bool) inMatrix[inNodeA][inNodeB]; } // check if there is a path between two node bool existPath( matrix<double> inMatrix, int inNodeA, int inNodeB ) { matrix<double> tmp = inMatrix; int size = inMatrix.size(); // check the way using a theoreme of adjacencyMatrix power for( int i = 0; i < size-1; i++) { if(helper::isConnected(tmp, inNodeA, inNodeB)) return true; tmp = helper::multiply(tmp, inMatrix); helper::displayMatrix(tmp); } return false; } // inFileNumber is the number of test file // isCostMatrix makes to know if matrix is costed or not helper::GraphInfos readGraphInfo(int inFileNumber, bool isCostMatrix) { matrix<string> tmpMatrix; string line; string token; // for knowing a size of the matrix int matrixSize = 0; // used to known if we are readind the first line or not bool isFirstLine = true; string verticesString; // local GraphInfo var that will be returned helper::GraphInfos gInfos; ostringstream oss; oss << inFileNumber; string str("../var/data/input" + oss.str() + ".txt"); row<string> tmp; // ifstream ifs; ifstream ifs(str); // check for opening of the file if(!ifs){ throw "INPUT_ERROR: The input file number " + to_string(inFileNumber) + " is unavailable"; }
Isaac
// ifs.widen('\n') =: '\n' is delimiter while(getline(ifs, line, ifs.widen('\n'))){ if(isFirstLine){ verticesString = line; // let's use lambda (closure javascript) to get verticesString length=matrixSize [&matrixSize, verticesString](){ for(auto __ : verticesString){ if(__ != ' '){ matrixSize++; } } }(); isFirstLine = false; continue; } // the size of ower matrix is matrixSize // from line make iss flow istringstream iss(line); for(int i = 0; i < matrixSize; i++){ iss >> token; cout << "token => " << token << endl; tmp.push_back(token); iss.clear(); } tmpMatrix.push_back(tmp); tmp.clear(); } if(unsigned(matrixSize) != tmpMatrix.size()) throw "INPUT_ERROR: The input file number " + to_string(inFileNumber) + "is wrong formated\n Please look at it may be it contains over \\n characters"; row<int> tmpVector(matrixSize); for(int i = 0; i < matrixSize; i++){ tmpVector.push_back(i); } // build really the matrix using the symetric properties for(auto i : tmpVector){ if(i == matrixSize - 1){ // this break is not very need but just for readability reasons break; } // filling of the empty upper triangular form diagonal // @ // @ @ // @ @ @ // @ @ @ @ for(int j = 0; j < matrixSize; j++){ tmpMatrix[i][j].assign(tmpMatrix[j][i]); } } // matrix is fully filled now; gInfos.graphMatrix = tmpMatrix; gInfos.verticesString = verticesString; gInfos.isCostMatrix = isCostMatrix; return gInfos; } int main(){ helper::GraphInfos gInfos; helper::displayMatrix(readGraphInfo(4,1).graphMatrix); }
Isaac
👆helper.cpp
Isaac
When I compile de helper.cpp file I get this error
Isaac
./include/helper.hpp:23:1: error: expected unqualified-id before ‘using’ using matrix = std::vector<std::vector<T>>; ^ ../include/helper.hpp:25:1: error: expected unqualified-id before ‘using’ using row = std::vector<T>; ^
Dima
Probably missing template
BinaryByter
i hate reading bad code
BinaryByter
that wasn't pstebinded
Dima
i hate reading bad code
So you never read your own ( ͡° ͜ʖ ͡°)
BinaryByter
Fuck off xD
Dima
Ew, that was webcpp ad
Isaac
Everyone started somewhere so your insults will be welcome
Isaac
https://pastebin.com/cuawmP7a
BinaryByter
BinaryByter
dafaq is this meme?
Isaac
https://pastebin.com/KzWDPX1A
BinaryByter
BinaryByter
undefined behaviour
Isaac
I have forget to remove it it is for degugging
BinaryByter
I have forget to remove it it is for degugging
anything with "__" in it is undefined behaviour
Mihail
More importantly which c++ version
BinaryByter
though such things should be 11 already 🤔
BinaryByter
MVE is required
Isaac
I run this g++ -c helper.cpp -o helper.o --std=c++11
Isaac
BinaryByter
inh ?
two underscores
Mihail
Also
Mihail
#noendl
Mihail
Might want to have a look at these
Mihail
No
Isaac
all is good now when i use -std=c++17 option
BinaryByter
okay
Mihail
Nice
Isaac
two underscores
Why, or how ?
Anonymous
That's good
BinaryByter
Why, or how ?
the compiler uses variable names with __ internally
BinaryByter
(the standard library too)
Isaac
the compiler uses variable names with __ internally
yeah I now ok ok but there is not internal variables named ___
Mihail
(the standard library too)
Those have one iirc
Isaac
Those have one iirc
Ok, I will get like bad pratice to use __ . Thanks
Mihail
Yes exactly
BinaryByter
Mihail
?
One _ not __
Mihail
(I think)
BinaryByter
no
BinaryByter
the standard library uses __