![JAR search and dependency download from the Maven repository](/logo.png)
gov.sandia.cognition.math.matrix.custom.CustomDiagonalMatrixFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cognitive-foundry Show documentation
Show all versions of cognitive-foundry Show documentation
A single jar with all the Cognitive Foundry components.
/*
* File: DiagonalMatrixFactoryOptimized.java
* Authors: Jeremy D. Wendt
* Company: Sandia National Laboratories
* Project: Cognitive Foundry
*
* Copyright 2015, 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.math.matrix.custom;
import gov.sandia.cognition.math.matrix.Matrix;
import gov.sandia.cognition.math.matrix.MatrixFactory;
/**
* Factory for diagonal matrices.
*
* @author Jeremy D. Wendt
* @since 4.0.0
*/
public class CustomDiagonalMatrixFactory
extends MatrixFactory
{
/** An instance of this class. */
public static CustomDiagonalMatrixFactory INSTANCE = new CustomDiagonalMatrixFactory();
/**
* {@inheritDoc}
* @return {@inheritDoc}
* @throws IllegalArgumentException if the input matrix isn't square
* (because diagonal matrices must be) or if the input matrix has non-zero
* entries on the diagonal.
*/
@Override
final public DiagonalMatrix copyMatrix(
final Matrix m)
{
return new DiagonalMatrix(m);
}
/**
* {@inheritDoc}
* @return {@inheritDoc}
* @throws IllegalArgumentException if the input dimensions are not square
* (because diagonal matrices must be)
*/
@Override
final public DiagonalMatrix createMatrix(
final int numRows,
final int numColumns)
{
if (numRows != numColumns)
{
throw new IllegalArgumentException("Diagonal matrices must be "
+ "sqaure. Non-square (" + numRows + " x " + numColumns
+ ") diagonal matrix requested.");
}
return new DiagonalMatrix(numRows);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy