org.lsmp.djep.vectorJep.function.MDot Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jep Show documentation
Show all versions of jep Show documentation
JEP is a Java library for parsing and evaluating mathematical expressions.
/*****************************************************************************
JEP - Java Math Expression Parser 2.24
December 30 2002
(c) Copyright 2002, Nathan Funk
See LICENSE.txt for license information.
*****************************************************************************/
package org.lsmp.djep.vectorJep.function;
import java.util.*;
import org.lsmp.djep.vectorJep.*;
import org.lsmp.djep.vectorJep.values.*;
import org.nfunk.jep.*;
/**
* The MDot operator.
* @author Rich Morris
* Created on 23-Feb-2004
*/
public class MDot extends MMultiply implements BinaryOperatorI
{
public MDot() {
numberOfParameters = 2;
}
public Dimensions calcDim(Dimensions l,Dimensions r) {
if(l.equals(r) && l.is1D()) return Dimensions.ONE;
return null;
}
/** calculates the value.
* @param res - results will be stored in this object
* @param lhs - lhs value
* @param rhs - rhs value
* @return res
*/
public MatrixValueI calcValue(MatrixValueI res,MatrixValueI lhs,MatrixValueI rhs) throws ParseException
{
return calcValue((Scaler) res,(MVector) lhs,(MVector) rhs);
}
public Scaler calcValue(Scaler res,MVector lhs,MVector rhs) throws ParseException
{
int len = lhs.getNumEles();
Object val = mul(lhs.getEle(0),rhs.getEle(0));
for(int i=1;i