public class LinearFunctionNx1 extends Diff1FunctionNx1Base
y = sum c[i]*in[i] + c[n]
Constructor and Description |
---|
LinearFunctionNx1()
Creates an empty LinearFunctionNx1
|
LinearFunctionNx1(double[] coefs)
Creates a new LinearFunctionNx1 with the specified coefficients.
|
LinearFunctionNx1(double m,
double b)
Creates a new LinearFunctionNx1 with a single argument
defined by
|
LinearFunctionNx1(VectorNd coefs)
Creates a new LinearFunctionNx1 with the specified coefficients.
|
Modifier and Type | Method and Description |
---|---|
LinearFunctionNx1 |
clone() |
boolean |
equals(LinearFunctionNx1 fxn)
Returns
true if fxn is equal to this function. |
double |
eval(VectorNd in)
Evaluates this function for the specified inputs.
|
double |
eval(VectorNd deriv,
VectorNd in)
Evaluates this function for the specified inputs.
|
double[] |
getCoefficients()
Returns the coefficients of this function.
|
int |
inputSize()
Queries the number of inputs expected by this function.
|
void |
scan(ReaderTokenizer rtok,
java.lang.Object ref)
Scans this element from a ReaderTokenizer.
|
void |
setCoefficients(double[] coefs)
Sets the coefficients of this function.
|
void |
setCoefficients(double m,
double b)
Sets this function to one with a single argument defined by
|
void |
write(java.io.PrintWriter pw,
NumberFormat fmt,
java.lang.Object ref)
Writes a text description of this element to a PrintWriter.
|
isWritable
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
evalDeriv
public LinearFunctionNx1()
public LinearFunctionNx1(double[] coefs)
coefs
- function coefficents (will be copied)public LinearFunctionNx1(VectorNd coefs)
coefs
- function coefficents (will be copied)public LinearFunctionNx1(double m, double b)
y = m*in[0] + b
m
- slope of the functionb
- intercept of the functionpublic void setCoefficients(double m, double b)
y = m*in[0] + b
m
- slope of the functionb
- intercept of the functionpublic void setCoefficients(double[] coefs)
coefs
- function coefficents (will be copied)public double[] getCoefficients()
public int inputSize()
public double eval(VectorNd in)
FunctionNx1.inputSize()
.eval
in interface FunctionNx1
eval
in class Diff1FunctionNx1Base
public double eval(VectorNd deriv, VectorNd in)
deriv
is not
null
, the derivative is also computed and returned in this
argument. The input vector size should equal the value returned by FunctionNx1.inputSize()
. If present, deriv
will be resized, if necessary, to
FunctionNx1.inputSize()
.eval
in interface Diff1FunctionNx1
eval
in class Diff1FunctionNx1Base
deriv
- if not null
, returns the derivative valuesin
- function input valuespublic void scan(ReaderTokenizer rtok, java.lang.Object ref) throws java.io.IOException
write
.scan
in interface Scannable
scan
in class Diff1FunctionNx1Base
rtok
- Tokenizer from which to scan the elementref
- optional reference object which can be used for resolving references to
other objectsjava.io.IOException
- if an I/O or formatting error occuredpublic void write(java.io.PrintWriter pw, NumberFormat fmt, java.lang.Object ref) throws java.io.IOException
scan
and complete
enough to allow full reconstruction of the element.write
in interface Scannable
write
in class Diff1FunctionNx1Base
pw
- stream for writing the elementfmt
- numeric formating informationref
- optional reference object which can be used for producing references to
other objectsjava.io.IOException
- if an I/O error occuredpublic boolean equals(LinearFunctionNx1 fxn)
true
if fxn
is equal to this function.public LinearFunctionNx1 clone()
clone
in interface Clonable
clone
in class Diff1FunctionNx1Base