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

gov.sandia.cognition.learning.function.distance.DefaultDivergenceFunctionContainer Maven / Gradle / Ivy

There is a newer version: 4.0.1
Show newest version
/*
 * File:                DefaultDivergenceFunctionContainer.java
 * Authors:             Justin Basilico
 * Company:             Sandia National Laboratories
 * Project:             Cognitive Foundry
 * 
 * Copyright March 24, 2008, 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.distance;

import gov.sandia.cognition.math.DivergenceFunction;
import gov.sandia.cognition.util.AbstractCloneableSerializable;
import gov.sandia.cognition.util.ObjectUtil;

/**
 * The {@code DefaultDivergenceFunctionContainer} class implements an object
 * that holds a divergence function. It is extended by various other classes
 * that contain divergence functions.
 * 
 * @param    The type of the first parameter to the divergence
 *      function.
 * @param    The type of the second parameter to the divergence
 *      function.
 * @author  Justin Basilico
 * @since   2.1
 */
public class DefaultDivergenceFunctionContainer
    extends AbstractCloneableSerializable
    implements DivergenceFunctionContainer
{
    /**
     * The internal divergence function for the object to use.
     */
    protected DivergenceFunction 
        divergenceFunction;
    
    /**
     * Creates a new instance of {@code DefaultDivergenceFunctionContainer}.
     */
    public DefaultDivergenceFunctionContainer()
    {
        super();
        
        this.setDivergenceFunction(null);
    }
    
    /**
     * Creates a new instance of {@code DefaultDivergenceFunctionContainer}.
     * 
     * @param   divergenceFunction The divergence function.
     */
    public DefaultDivergenceFunctionContainer(
        final DivergenceFunction
            divergenceFunction)
    {
        super();
        
        this.setDivergenceFunction(divergenceFunction);
    }
    
    /**
     * Creates a new instance of {@code DefaultDivergenceFunctionContainer}.
     * 
     * @param   other The other object to copy.
     */
    public DefaultDivergenceFunctionContainer(
        final DefaultDivergenceFunctionContainer other)
    {
        this(ObjectUtil.cloneSmart(other.getDivergenceFunction()));
    }

    @Override
    public DefaultDivergenceFunctionContainer clone()
    {
        @SuppressWarnings("unchecked")
        final DefaultDivergenceFunctionContainer result =
            (DefaultDivergenceFunctionContainer) 
                super.clone();
        result.divergenceFunction = ObjectUtil.cloneSmart(this.divergenceFunction);
        return result;
    }
    
    /**
     * Gets the divergence function used by this object.
     * 
     * @return  The divergence function.
     */
    public DivergenceFunction 
        getDivergenceFunction()
    {
        return divergenceFunction;
    }
    
    /**
     * Sets the divergence function used by this object.
     * 
     * @param   divergenceFunction The divergence function.
     */
    public void setDivergenceFunction(
        final DivergenceFunction 
        divergenceFunction)
    {
        this.divergenceFunction = divergenceFunction;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy