help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Hypermatrix in C++


From: Shamika Mohanan
Subject: Hypermatrix in C++
Date: Mon, 28 Nov 2016 12:22:25 +0530

Hello,

1. I have the following code in C++

octave_value_list out = feval (pstData[0], in, o);
for (p = 0; p <o; p++)
{  
        dim_vector u=out(p).dims();
        if(u.length()>=3)
        {
            //Do something with hypermatrix
        }
       
       if(u.length()<=2)
        {
            //Do something with 2D matrix
        }
}

Is there a better way to identify 2D/hypermatrices?

2. To identify a 2D double matrix and get its matrix dimensions, I'm using the following code

dim_vector d = (out(p).matrix_value().dims());
pdbl_op = (double*)malloc(sizeof(double) * d(0) * d(1));
Matrix x=(out(p).matrix_value ());
for(int l = 0 ; l < d(0) ; l++)
{
  for(int m = 0 ; m < d(1) ; m++)
  {
    pdbl_op[l+d(0)*m]=x(l,m);
  }
}


How do I access double/complex/int hypermatrix elements? Is there something like NDArray x=(out(p).ndarray_value());? (I tried this but this shows errors)

Regards,
Shamika

reply via email to

[Prev in Thread] Current Thread [Next in Thread]