All Downloads are FREE. Search and download functionalities are using the official Maven repository.

gov.sandia.cognition.learning.function.vector.ScalarBasisSet Maven / Gradle / Ivy

There is a newer version: 4.0.1
Show newest version
/*
 * File:                ScalarBasisSet.java
 * Authors:             Kevin R. Dixon
 * Company:             Sandia National Laboratories
 * Project:             Cognitive Foundry
 * 
 * Copyright Nov 30, 2007, Sandia Corporation.  Under the terms of Contract
 * DE-AC04-94AL85000, there is a non-exclusive license for use of this work by
 * or on behalf of the U.S. Government. Export of this program may require a
 * license from the United States Government. See CopyrightHistory.txt for
 * complete details.
 * 
 */

package gov.sandia.cognition.learning.function.vector;

import gov.sandia.cognition.evaluator.Evaluator;
import gov.sandia.cognition.math.matrix.VectorFactory;
import gov.sandia.cognition.math.matrix.Vector;
import gov.sandia.cognition.math.matrix.VectorOutputEvaluator;
import gov.sandia.cognition.util.AbstractCloneableSerializable;
import gov.sandia.cognition.util.CloneableSerializable;
import java.util.ArrayList;
import java.util.Collection;

/**
 * Collection of scalar basis functions, where the ith function operates
 * on the ith element of the output Vector
 * 
 * @param  Input class that the basis function operate upon
 * @author Kevin R. Dixon
 */
public class ScalarBasisSet
    extends AbstractCloneableSerializable
    implements Evaluator,
    VectorOutputEvaluator
{

    /**
     * Collection of scalar basis functions, where the ith function operates
     * on the ith element of the output Vector
     */
    private Collection> basisFunctions;

    /** 
     * Creates a new instance of ScalarBasisSet 
     * @param basisFunctions 
     * Collection of scalar basis functions, where the ith function operates
     * on the ith element of the output Vector
     */
    public ScalarBasisSet(
        Collection> basisFunctions )
    {
        this.setBasisFunctions( basisFunctions );
    }

    /**
     * Copy Constructor
     * @param other ScalarBasisSet to copy
     */
    public ScalarBasisSet(
        ScalarBasisSet other )
    {
        this( new ArrayList>(
            other.getBasisFunctions() ) );
    }

    public int getOutputDimensionality()
    {
        return this.getBasisFunctions().size();
    }

    public Vector evaluate(
        InputType input )
    {

        Vector output = VectorFactory.getDefault().createVector(
            this.getOutputDimensionality() );

        int i = 0;
        for (Evaluator f : this.getBasisFunctions())
        {
            output.setElement( i, f.evaluate( input ) );
            i++;
        }

        return output;
    }

    /**
     * Getter for basisFunctions
     * @return
     * Collection of scalar basis functions, where the ith function operates
     * on the ith element of the output Vector
     */
    public Collection> getBasisFunctions()
    {
        return this.basisFunctions;
    }

    /**
     * Setter for basisFunctions
     * @param basisFunctions
     * Collection of scalar basis functions, where the ith function operates
     * on the ith element of the output Vector
     */
    public void setBasisFunctions(
        Collection> basisFunctions )
    {
        this.basisFunctions = basisFunctions;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy