![]()
Note
Although you have been looking at the source code in $TUTORIAL_SRC, this exercise should be done in the Bocca project you created in Chapter 3.
$
cd $WORKDIR/demo
In this section, you will use the LinearOp components and driver described earlier as a template to develop a driver and a component that provides the NonLinearOp port. The specification of this port is in $STUDENT_SRC/ports/sidl/arrayop.NonLinearOp.sidl, and is repeated here for convenience.
/** This port can be used to evaluate a linear matrix operation
* of the form
* R = Sum[i=1, N] {Alpha_i log(A_i)} + Sum[j=1, N] {Beta_j A_j .* M_j}
* Where:
* alpha_i, Beta_j Double scalar
* A_i, M_j Double array of size [m, n]
* log(A_i) Elementwise log (base 10) of matrix A_i
* A_j .* M_j Elementwise multiplication of A_j and M_j
*/
interface NonLinearOp extends gov.cca.Port
{
/** Initialize (or Re-Initialize) internal state in preparation
* for accumulation.
*/
void init();
/** Evaluate Acc = Acc + alpha log(A) where
* log(A) Elementwise log (base 10) of array A
* Acc The internal accumulator maintained by implementors
* of this interafce
* return the result in array R
*/
int logMat (in double alpha,
in rarray<double, 2> A(m, n),
inout rarray<double, 2> R(m, n),
in int m,
in int n);
/** Evaluate Acc = Acc + beta A .* M, where
* .* denotes elementwise multiplications of arrays
* Acc the internal accumulator maintained by implementors
* of this interafce
* return the result in array R
*/
int mulMatMat ( in double beta,
in array<double, 2> A,
in array<double, 2> M,
out array<, 2> R);
/** Get result of nonlinear operation accumulation.
*
int getResult (inout rarray<double, 2> R(m, n),
in int m,
in int n);
}
| $ |
bocca create port arrayop.NonLinearOp
\
--import-sidl=arrayop.NonLinearOp@\ $STUDENT_SRC/ports/sidl/arrayop.NonLinearOp.sidl |
| $ |
bocca create component arrayOps.NonLinearOp
\
--provides=arrayop.NonLinearOp@NonLinearPort \ --lang=LANG |
| $ |
bocca create component arrayDrivers.NLinearDriver
\
--provides=gov.cca.ports.GoPort@Go \ --uses=arrayop.NonLinearOp@NonLinearPort --lang=LANG |
2010-08-11