Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
raffaello-camoriano opened this issue Sep 3, 2014 · 0 comments

Comments

@raffaello-camoriano
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant