help-octave
[Top][All Lists]
Advanced

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

Re: How to create a 3D matrix in an oct-file?


From: Jaroslav Hajek
Subject: Re: How to create a 3D matrix in an oct-file?
Date: Tue, 12 Jan 2010 10:10:40 +0100

On Tue, Jan 12, 2010 at 10:04 AM, Fredrik Lingvall <address@hidden> wrote:
> Hi all,
>
> I have tried this:
>
> printf("%d %d %d\n",NN, N_alpha,N_beta);
>
> dim_vector dv (3);
> printf("%d\n",dv.length());
>
> dv(0) = NN;
> dv(1) = N_alpha;
> dv(2) = N_beta;
>
> NDArray p_mat(dv);
> p = p_mat.fortran_vec();
>
> In an oct-file but it fails with:
>
> 20 11 11
> 2
> octave: /usr/local/include/octave-3.2.3/octave/dim-vector.h:125:
> octave_idx_type& dim_vector::dim_vector_rep::elem(int): Assertion `i >= 0 &&
> i < ndims' failed.
> panic: Aborted -- stopping myself...
> Aborted
>
> Why is the length of the dim_vector only 2 when I set it to 3 in the
> constructor?
>

Because the constructor does something else than you think it does.
To construct a 3d dim_vector, do
dim_vector dv (NN, N_alpha, N_beta);


-- 
RNDr. Jaroslav Hajek, PhD
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz


reply via email to

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