Bonjour j'ai un petit soucis avec eigen et j'ai pas trouvé beaucoup d'exemple bien que le tutorial sur le site officiel soi bien fait.
J'ai un fichier contenant une matrice je parse le fichier afin de créer une matrice avec eigen. Seulement a l'exécution du programme érreur.
ACOM: /usr/include/eigen2/Eigen/src/Core/Coeffs.h:96: typename Eigen::ei_traits<T>::Scalar& Eigen::MatrixBase<Derived>::operator()(int, int) [with Derived = Eigen::Matrix<int, 10000, 10000, 2, 10000, 10000>]: Assertion `row >= 0 && row < rows() && col >= 0 && col < cols()' failed.
Le fichier en cause:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
namespace tools
{
	Eigen::MatrixXi createMatrix( std::wstring path )
	{
		// Create flow
		std::ifstream file(toANSI(path).c_str(), std::ios::in);
 
		// Current line
		std::string line;
 
		unsigned int row, column = 0;
 
		// Matrix
		Eigen::MatrixXi matrix;
 
		// typedef for a better readable code
		typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
 
		// The separator
		boost::char_separator<char> separator( " " );
 
 
		// If open file success
		if (file)
		{
			while (std::getline(file, line))
			{
				// Personal tokeniser
				tokenizer tokens( line, separator );
 
				for (tokenizer::iterator tokenIterator = tokens.begin(); tokenIterator != tokens.end(); ++tokenIterator)
				{
					std::string tempString	= *tokenIterator;
					std::wcout << atoi( tempString.c_str() ) << std::endl;
					matrix(column, row)		= atoi( tempString.c_str() );
					++column;
				}
				++row;
			}
				file.close();
		}
		else
		{
			std::wcerr << "Error! Can not open file: " << path << std::endl;
			exit(EXIT_FAILURE);
		}
 
		return matrix;
	}
}
Je ne connais pas à l'avance la taille de la matrice. ET les matrices peuvent être énormes je ne souhaite pas stocker au fur et à mesure, sinon je vais saturer la mémoire vive.
En vous remerciant de vos conseils