help-octave
[Top][All Lists]
Advanced

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

Re: size of NDArrays


From: Thomas L. Scofield
Subject: Re: size of NDArrays
Date: Mon, 11 Aug 2008 15:00:00 -0400


Oops.  m.ndims () is what I meant.

Anyway, your response tells me just what I needed to know.  Heretofore I have assumed a dim_vector could have length 1, 2 or 3 only, and that after that one had to use an Array<octave_idx>.

Can I safely assume that a dim_vector is simply an Array<octave_idx>, but that there are constructors for dim_vector only in the cases where lengths are 1, 2 or 3?

Thanks.


On Aug 11, 2008, at 2:50 PM, Søren Hauberg wrote:

man, 11 08 2008 kl. 14:37 -0400, skrev Thomas L. Scofield:
I can use

   m.dims ()


to find out how many coordinates the new array m has.  But how do I
find out the range of values in a particular coordinate?  That is, if
the original call within Octave sent a matrix A satisfying


   size(A) = [256   256   3   10]


which is what is stored in the argument param, then


   m.dims ()


would equal 4.  But what method tells me that the largest valid entry
in the 4th position is 9?

Actually, m.dims () return a 'dim_vector' which would contain the values
[256   256   3   10]. I can't remember the exact syntax but I believe
you can do something like this:

  dim_vector dims = m.dims ();
  for (int i = 0; i < dims.length (); i++)
    printf ("%d ", dims (i));

which should print "256 256 3 10 ". BTW. the m.ndims () return the
number 4 in this case.

Søren


Thomas L. Scofield
--------------------------------------------------------
Associate Professor
Department of Mathematics and Statistics
Calvin College
--------------------------------------------------------


_______________________________________________
Help-octave mailing list

Thomas L. Scofield
--------------------------------------------------------
Associate Professor
Department of Mathematics and Statistics
Calvin College
--------------------------------------------------------


reply via email to

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