当前位置: 技术问答>java相关
希望各位大侠不吝赐教
来源: 互联网 发布时间:2015-01-25
本文导语: 我设计的一个单值函数类: ========================cut here========================= /**the abstract class of function * designed according to matlab * Author:weiming * Vision:1.0 * Date:4/6/2001 */ package Mathematica.Functions; public abstract ...
我设计的一个单值函数类:
========================cut here=========================
/**the abstract class of function
* designed according to matlab
* Author:weiming
* Vision:1.0
* Date:4/6/2001
*/
package Mathematica.Functions;
public abstract class Function{
public String name="Function";
public String expression=null;
public int type=0;
protected double factor=1.0;
//构造函数,其实现类使用
public Function(String name,String expression,int type){
this.name=name;
this.expression=expression;
this.type=type;
}
public Function(String name,String expression){
this.name=name;
this.expression=expression;
this.type=FunctionType.Unknown;//另实现
}
public Function(String name){
this.name=name;
this.expression=null;
this.type=FunctionType.Unknown;
}
public Function(){
this.name=null;
this.expression=null;
}
public void setName(String str){
this.name=str;
}
public void setExpression(String str){
this.expression=str;
}
public void setType(int type){
this.type=type;
}
public String toString(){
return name+": "+expression;
}
public abstract double value(double[] vars) throws Exception;
}
========================cut here=========================
我一直都想用一个String类对象expression来构造函数对象,如:
expression="f(x,y,z)=Math.exp(2.0)*(1/x^2)+Math.sin(y)+Math.Log(z)"
那么,这个类就不用声明为abctract,那位大侠能帮我设计这样一个函数,
public double value(double[] vars) throws Exception;
要求读取expression,直接实现单值函数求值。括号中变量依次为var[0],var[1],
var[2]......,如果不用java,能否给我一个dll,函数形如double value(String expression,double[] vars)??
希望各位大侠不吝赐教,小弟在此先谢过了.
========================cut here=========================
/**the abstract class of function
* designed according to matlab
* Author:weiming
* Vision:1.0
* Date:4/6/2001
*/
package Mathematica.Functions;
public abstract class Function{
public String name="Function";
public String expression=null;
public int type=0;
protected double factor=1.0;
//构造函数,其实现类使用
public Function(String name,String expression,int type){
this.name=name;
this.expression=expression;
this.type=type;
}
public Function(String name,String expression){
this.name=name;
this.expression=expression;
this.type=FunctionType.Unknown;//另实现
}
public Function(String name){
this.name=name;
this.expression=null;
this.type=FunctionType.Unknown;
}
public Function(){
this.name=null;
this.expression=null;
}
public void setName(String str){
this.name=str;
}
public void setExpression(String str){
this.expression=str;
}
public void setType(int type){
this.type=type;
}
public String toString(){
return name+": "+expression;
}
public abstract double value(double[] vars) throws Exception;
}
========================cut here=========================
我一直都想用一个String类对象expression来构造函数对象,如:
expression="f(x,y,z)=Math.exp(2.0)*(1/x^2)+Math.sin(y)+Math.Log(z)"
那么,这个类就不用声明为abctract,那位大侠能帮我设计这样一个函数,
public double value(double[] vars) throws Exception;
要求读取expression,直接实现单值函数求值。括号中变量依次为var[0],var[1],
var[2]......,如果不用java,能否给我一个dll,函数形如double value(String expression,double[] vars)??
希望各位大侠不吝赐教,小弟在此先谢过了.
|
可以试一试mathlab的activeX控件
|
如果人人都能给自己加分,人人都是成了顶尖专家了。呵呵。
|
问题解决了,应该高兴才对亚。分数就当扔了听个响 ^_^