Ch Professional Edition Demos -- Computational array

/* Example 1:
   An array qualified by type qualifier 'array' is called computational array. 
   A computational array is treated as a first-class object as in Fortran 90. 
*/
#include <stdio.h>
#include <array.h>

int main() {
    array double A[2][3] = {1, 2, 3,
                            4, 5, 6};
    array double B[3][2];
    printf("A= \n%f \n", A+A);
    B = 2*transpose(A);
    printf("B= \n%f \n", B);
}


The output is:
A=
2.000000 4.000000 6.000000
8.000000 10.000000 12.000000

B=
2.000000 8.000000
4.000000 10.000000
6.000000 12.000000


/* Example 2: 
   A function can return a computational array as well. 
*/
#include <stdio.h>
#include <array.h>

array double fun(int i)[3] {
   array double a[3]={1,2,3};
   a = a+a;
   return a;
}
int main() {
   array double b[3];
   b = fun(3);
   printf("%f \n", b);
}

The output is:
2.000000 4.000000 6.000000