[Top][All Lists]

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

Re: Creating double hypermatrix in C++

From: Shamika Mohanan
Subject: Re: Creating double hypermatrix in C++
Date: Wed, 19 Oct 2016 11:25:44 +0530

Suppose I want to create a 4 page hyper matrix with 2 rows and 3 columns, is the following correct?

dim_vector d(2, 3, 4);
NDArray ndarray_double(d,0.0);

for( a= 0 ;a<4 ; a++)//Page
 for( b= 0 ;b<2 ; b++)//Rows
   for (c=0;c<3;c++) //Columns 
     ndarray_double (b,c,a) = some_value;


On Wed, Oct 19, 2016 at 11:02 AM, Carlo de Falco <address@hidden> wrote:

Il 19 ott 2016 7:19 AM, "Shamika Mohanan" <address@hidden> ha scritto:
> Hello,
> It works if the dimensions are specified. I had to change a to 0 based indexing. What does 4 refer to in dim_vector d(4, iRows, iCols);? Number of matrices?
> Shamika

It's the range of variation of the first index, you had

for (a = 1; a ≤ 3; a++)

Which means "a" can take the maximum value of 3, as the minimum value is always 0, that means "a" can take 4 different values.

In Octave sources the indices of a 3dimensional matrix are some times referred to as

1st index = row index
2nd index = column index
3rd index = page index

In this notation your matrix had 4 rows, "iRows" columns and "iCols" pages and "a" is the "row index".


reply via email to

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