|
| John McHenry <john_d_mchenry@yahoo.com>
Sent by: blitz-support-bounces@oonumerics.org
02/08/2004 01:57
Please respond to Support list for Blitz++
|
To: blitz-support@oonumerics.org
cc:
Subject: [Blitz-support] Matlab-like stuff |
> Hi there:
>
> I want to know if I can do some simple Matlab stuff with blitz like these Matlab examples,
>
> N = 10000;
> A = [7:N]; % create a length N-6 array
>
> How do you do it in blitz?
This one is easy:
int N = 10000;
Array<float,1> A(Range(1,N-6));
A = tensor::i+6;
the tensor::i is an index placeholder, check the manual for that, that allows you to write expressions with blitz objects in the same way you would with tensors on paper, it is described in the manual.
>Then there's this example,
>
>M = [1:4; 5:8; 9:12]
>M =
> 1 2 3 4
> 5 6 7 8
> 9 10 11 12
I would do this one as follows:
Array<float,2> M(Range(1,3),Range(1,4));
M = 4*(tensor::i-1)+tensor::j;
as you see, i in the first index, j the second and so on, in the manual it explains how to do this sort of things in more detail, so as long as you can write M(i,j) as an expresion of i and j you are done.
>M(1,1:3) = [3:-1:1]
>M =
> 3 2 1 4
> 5 6 7 8
> 9 10 11 12
I am not sure about this one, perhaps someone with more experience in blitz can help? I would just use the same method as above and then change the first row by hand.
Hope this helps
______________________________________________________________________
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom
they are addressed.
If you have received this email in error please notify the
originator of the message.
Any views expressed in this message are those of the individual
sender, except where the sender specifies and with authority,
states them to be the views of Malvern Instruments.
______________________________________________________________________