VALUE x0;
x0 = na_make_object(5,2,array_shape,cNArray);/* array_shape is an array containing {n,1} */
GetNArray(x0,na_x0);
for (i = 1; i <= array_shape[0]; i++)
na_x0->ptr[i - 1] = 1.0; ....
Here,I have specified all the elements in na_x0 into 1.0,
then how to put the latest value into x0?
I checked almost all the methods in narray.c,but it seems that they can only
create emply NArray objects or copy from other objects.
VALUE x0;
x0 = na_make_object(5,2,array_shape,cNArray);/* array_shape is an array
containing {n,1} */
GetNArray(x0,na_x0);
for (i = 1; i <= array_shape[0]; i++)
na_x0->ptr[i - 1] = 1.0;
Here should be;
*(double*)(na_x0->ptr[i - 1]) = 1.0;
Here,I have specified all the elements in na_x0 into 1.0,
then how to put the latest value into x0?
----- Original Message -----
From: "Masahiro TANAKA" <masa@ir.isas.ac.jp>
To: "ruby-talk ML" <ruby-talk@ruby-lang.org>; <caili@cdgwbn.com.cn>
Sent: Sunday, September 12, 2004 1:50 PM
Subject: Re: A simple NARRAY question
Hi,
> Problem:How can I put data into a NArray object
>
> my code looks like this:
>
> VALUE x0;
> x0 = na_make_object(5,2,array_shape,cNArray);/* array_shape is an array
> containing {n,1} */
> GetNArray(x0,na_x0);
> for (i = 1; i <= array_shape[0]; i++)
> na_x0->ptr[i - 1] = 1.0;
Here should be;
*(double*)(na_x0->ptr[i - 1]) = 1.0;
> Here,I have specified all the elements in na_x0 into 1.0,
> then how to put the latest value into x0?
Cai Li
----- Original Message ----- From: "Masahiro TANAKA" <masa@ir.isas.ac.jp>
To: "ruby-talk ML" <ruby-talk@ruby-lang.org>; <caili@cdgwbn.com.cn>
Sent: Sunday, September 12, 2004 1:50 PM
Subject: Re: A simple NARRAY question
a
Hi,
Problem:How can I put data into a NArray object
my code looks like this:
VALUE x0;
x0 = na_make_object(5,2,array_shape,cNArray);/* array_shape is an array containing {n,1} */
GetNArray(x0,na_x0);
for (i = 1; i <= array_shape[0]; i++)
na_x0->ptr[i - 1] = 1.0;
Here should be;
*(double*)(na_x0->ptr[i - 1]) = 1.0;
Here,I have specified all the elements in na_x0 into 1.0,
then how to put the latest value into x0?