Raw arrays (and vectors) are used as arguments in the call to mulMatVec. Note that multidimensional SIDL raw arrays are always assumed to use column-major storage. This requirement necessitates special treatment when calling methods that use SIDL raw arrays as arguments from languages that follow a default row-major array storage order (C and C++). The caller may choose to alter the memory layout of the array argument throughout its entire lifetime, or alternatively perform a matrix transpose operation on `native' arrays before and after every call to a SIDL method that uses raw arrays. In the example presented here, we have chosen to adopt column-major storage throughout the lifetime of the raw array argument A, as shown in the initialization code shown below
/* _ _ _ _ _ _
* | 1.0 4.0 | | 1.0 | | 3.0 |
* A = | 2.0 5.0 | v1 = | 2.0 | sda1 = | 4.0 |
* | 3.0 6.0 | - - | 5.0 |
* - - - -
*
* Note that A needs to be stored in column-major order to make
* the call using SIDL raw arrays
*/
value = 0.0;
for (i = 0; i <= m; i++){
for (j = 0; j <= n; j++){
A[i*n+j] = (value += 1.0);
}
}
When making a call to a SIDL method that has SIDL raw arrays arguments, the dimensions of those arrays must be explicitly included in the argument list in the SIDL specification. No special `wrapping' of native arrays is needed to make a call using SIDL raw arrays arguments. This can be seen in the call to the mulMatVec method.
retval = arrayop_LinearOp_mulMatVec(linopPort, alpha, A, v1, y, m , n,
&throwaway_excpt);
if (retval != 0){
fprintf(stderr, "Error:: %s:%d: Error in call to mulMatVec() \n",
__FILE__, __LINE__);
return(-1);
}
The requirement to use column-major memory layout is one of the restrictions imposed by Babel to allow for the use of raw arrays. See the Babel User Guide for the complete list.
David E. Bernholdt [bek] 574-3147 2009-08-21