![JAR search and dependency download from the Maven repository](/logo.png)
com.asher_stern.crf.function.optimization.LineSearchUtilities Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of CRF Show documentation
Show all versions of CRF Show documentation
Implementation of linear-chain Conditional Random Fields (CRF) in pure Java
package com.asher_stern.crf.function.optimization;
import static com.asher_stern.crf.utilities.VectorUtilities.*;
import com.asher_stern.crf.function.DerivableFunction;
/**
* A collection of static helper functions, needed for some implementations of {@link LineSearch}.
*
* @author Asher Stern
* Date: Nov 7, 2014
*
*/
public class LineSearchUtilities
{
/**
* Returns f(x+\alpha*d), where "x" is the given point, "d" is the given direction, and "\alpha" is some scalar.
*/
public static double valueForAlpha(DerivableFunction function, double[] point, double[] direction, double alpha)
{
return function.value(addVectors(point, multiplyByScalar(alpha, direction)));
}
/**
* Returns the (value of the) derivation of f(x+\alpha*d), where both x and d are considered constant vectors, and
* the only variable is \alpha. So f(x+\alpha*d) is a function of single variable, and the derivation is derivation
* by the variable \alpha.
* @return the value of the derivation of f(x+\alpha*d) for the given \alpha.
*/
public static double derivationForAlpha(DerivableFunction function, double[] point, double[] direction, double alpha)
{
return product(
function.gradient( addVectors(point, multiplyByScalar(alpha, direction) ) ),
direction);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy