Closed raffaello-camoriano closed 10 years ago
I could replicate your problem. It seems that the method "subvec" tried to use a non existent method data(). In the latest commit the issue is fixed. Please care that in your first demo program, the size of P (100, 50), is not consistent with the size (50) of the columns you are trying to set. After changing the number of rows of P to 50 I get the expected output.
Andrea
I have modified my test program as follows, thanks for reporting that:
#include <iostream>
#include <string>
#include "gurls++/gvec.h"
#include "gurls++/gmat2d.h"
using namespace gurls;
using namespace std;
typedef double T;
int main()
{
gMat2D<T> M(gMat2D<T>::zeros(10,10) + 1);
cout << "M initialized: " << endl << M << endl;
gMat2D<T> P(gMat2D<T>::zeros(5,5));
cout << "P initialized: " << endl << P << endl;
// Initialize P
gVec<T> tmpCol(10);
gVec<T> tmpCol1(5);
for ( int i = 0 ; i < 5 ; ++i )
{
tmpCol = M(5 + i);
tmpCol1 = tmpCol.subvec( (unsigned int) 5 , (unsigned int) 0 );
P.setColumn( tmpCol1 , (long unsigned int) i);
}
cout << "Modified P: " << endl << P << endl;
}
After pulling your latest changes, the project compiles and the result is correct.
kammo@kammo-Latitude-E5540:~/Repos/gurlssandbox/build/bin$ ./subVecTest2
M initialized:
[ 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 ]
P initialized:
[ 0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0 ]
Modified P:
[ 1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1 ]
Thanks a lot.
I have experienced problems at compile time with method gvec::subvec(unsigned int len, unsigned int start=0) const .
Here is a dummy program I have prepared for illustrating the issue. Its goal is to initialize matrices N and P starting from 100 x 100 matrix M, such that, in MATLAB syntax, P = M(1:100,51:100).
The compiling error is the following:
At the moment I am using the following workaround based on the setColumn method to overcome the problem, but it's quite verbose and probably inefficient in large-scale.