Next: , Up: Realvec

7.3.1 Reading and writing to a realvec

Realvecs may be accessed using var_name(index) = value.

Non-pointer way (allocation in stack)
     mrs_natural i,j;
     realvec foo;
     for (i=0; i<10; i++) {
     	foo(i) = i;
     for (i=0; i<10; i++) {
     realvec bar;
     for (i=0; i<5; i++) {
     	for (j=0; j<10; j++) {
     		bar(i,j) = i+j;
Pointer way (allocation on heap)
     // pointer for this example
     realvec *baz;
     // automatically calls calls create
     baz = new realvec(10,20);
     // we could do it this way if we wanted (instead of the above line)
     //baz = new realvec;
     for (i=0; i<10; i++) {
     	for (j=0; j<20; j++) {
     		(*baz)(i,j) = i+j;
     delete baz;  // don't forget to free the allocated memory