Skip to content

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

@raffaello-camoriano

Description

@raffaello-camoriano

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions