LCSL / GURLS

GURLS: a Least Squares Library for Supervised Learning
http://lcsl.mit.edu/#/downloads/gurls
63 stars 37 forks source link

Issue with gMat2D<T>::submatrix(const gMat2D<T>& other, unsigned long r, unsigned long c) #14

Open raffaello-camoriano opened 10 years ago

raffaello-camoriano commented 10 years ago

I have tried to use the submatrix method for initializing a 10 x 5 matrix N from the first columns and rows of the 10 x 10 matrix M.

I am probably missing something, since it seems that N is not assigned the expected values of M (all ones). Any suggestions?

#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> N(gMat2D<T>::zeros(10,5));

    // Initialize N
    M.submatrix(N , 10 , 5);
    cout << "N initialized: " << endl << N << endl;
}

Output:

kammo@kammo-Latitude-E5540:~/Repos/gurlssandbox/build/bin$ ./submatrixTest 
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 ]

N 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
  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 ]

Thank you.