KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > lsmp > djep > matrixJep > MatrixOperatorSet


1 /* @author rich
2  * Created on 27-Jul-2003
3  *
4  * This code is covered by a Creative Commons
5  * Attribution, Non Commercial, Share Alike license
6  * <a HREF="http://creativecommons.org/licenses/by-nc-sa/1.0">License</a>
7  */

8 package org.lsmp.djep.matrixJep;
9 import org.lsmp.djep.matrixJep.function.*;
10 import org.lsmp.djep.vectorJep.function.*;
11 import org.nfunk.jep.*;
12 import org.lsmp.djep.xjep.*;
13 /**
14  * The set of operators used in matricies.
15  *
16  * @author Rich Morris
17  * Created on 27-Jul-2003
18  */

19 public class MatrixOperatorSet extends XOperatorSet {
20     protected Operator TENSOR = new XOperator("TENSOR",new MList(),XOperator.NARY);
21     public Operator getMList() { return TENSOR; }
22
23     public MatrixOperatorSet() {
24         super();
25         OP_ADD.setPFMC(new MAdd());
26         OP_SUBTRACT.setPFMC(new MSubtract());
27         // TODO fix commutatitivity for matrix mult. How?
28
OP_MULTIPLY.setPFMC(new MMultiply());
29         OP_POWER.setPFMC(new MPower());
30         OP_UMINUS.setPFMC(new MUMinus());
31         OP_DOT.setPFMC(new MDot());
32 // OP_CROSS= new XOperator("^^","^",new ExteriorProduct(),XOperator.BINARY+XOperator.RIGHT);
33
OP_CROSS= new XOperator("^^","^",new ExteriorProduct(),XOperator.BINARY+XOperator.RIGHT,((XOperator) OP_CROSS).getPrecedence());
34 // OP_CROSS.setPFMC(new ExteriorProduct());
35
OP_ASSIGN.setPFMC(new MAssign());
36     }
37     
38     public Operator[] getOperators()
39     {
40         Operator ops1[] = super.getOperators();
41         Operator ops2[] = new Operator[ops1.length+1];
42         System.arraycopy(ops1,0,ops2,0,ops1.length);
43         ops2[ops1.length]= TENSOR;
44         return ops2;
45     }
46 }
47
Popular Tags