⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 externalelementwisefunction.java

📁 JAVA 数学程序库 提供常规的数值计算程序包
💻 JAVA
字号:
package jmathlib.core.functions;

import jmathlib.core.tokens.numbertokens.DoubleNumberToken;
import jmathlib.core.tokens.OperandToken;
import jmathlib.core.tokens.Token;

/**Base class for all external function classes which work element wise*/
abstract public class ExternalElementWiseFunction extends ExternalFunction
{

    /**
     *  standard function for evaluation of general external functions
     *  @param operands
     *  @return 
     */
    public OperandToken evaluate(Token[] operands)
    {

        // function works for one argument only
        if (getNArgIn(operands)!=1)
            throwMathLibException(name + " number of arguments < 1");

        // works on numbers only
        if (!(operands[0] instanceof DoubleNumberToken))
            throwMathLibException(name + " only works on numbers");

        // get number token
        DoubleNumberToken numOp = (DoubleNumberToken)operands[0];
        
        // get dimension of number token (2dimensional, 3dim, ....)
        int[] dim = numOp.getSize();
        
        // ceate array of correct size with dimensions "dim"
        DoubleNumberToken num = new DoubleNumberToken(dim, null, null);
        
        // call element evaluation for all values inside the DoubleNumberToken
        for (int i=0; i< numOp.getNumberOfElements(); i++)
        {
            num.setValueComplex(i, evaluateValue( numOp.getValueComplex(i) ));
        }
        
        return num;
        

    } // end evaluate

    
    // all subclasses of this cluss MUST implement the method below
    //abstract public double[] evaluateValue(double[] complex);
    abstract public double[] evaluateValue(double[] complex);
    
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -