alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Commons Math example source code file (SingularValueDecomposition.java)

This example Commons Math source code file (SingularValueDecomposition.java) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Commons Math tags/keywords

decompositionsolver, decompositionsolver, illegalargumentexception, illegalargumentexception, realmatrix, realmatrix, singularvaluedecomposition, singularvaluedecomposition

The Commons Math SingularValueDecomposition.java source code

/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.commons.math.linear;



/**
 * An interface to classes that implement an algorithm to calculate the
 * Singular Value Decomposition of a real matrix.
 * <p>
 * The Singular Value Decomposition of matrix A is a set of three matrices: U,
 * ? and V such that A = U × ? × V<sup>T. Let A be
 * a m × n matrix, then U is a m × p orthogonal matrix, ? is a
 * p × p diagonal matrix with positive or null elements, V is a p ×
 * n orthogonal matrix (hence V<sup>T is also orthogonal) where
 * p=min(m,n).
 * </p>
 * <p>This interface is similar to the class with similar name from the
 * <a href="http://math.nist.gov/javanumerics/jama/">JAMA library, with the
 * following changes:</p>
 * <ul>
 *   <li>the norm2 method which has been renamed as {@link #getNorm()
 *   getNorm},</li>
 *   <li>the cond method which has been renamed as {@link
 *   #getConditionNumber() getConditionNumber},</li>
 *   <li>the rank method which has been renamed as {@link #getRank()
 *   getRank},</li>
 *   <li>a {@link #getUT() getUT} method has been added,
 *   <li>a {@link #getVT() getVT} method has been added,
 *   <li>a {@link #getSolver() getSolver} method has been added,
 *   <li>a {@link #getCovariance(double) getCovariance} method has been added.
 * </ul>
 * @see <a href="http://mathworld.wolfram.com/SingularValueDecomposition.html">MathWorld
 * @see <a href="http://en.wikipedia.org/wiki/Singular_value_decomposition">Wikipedia
 * @version $Revision: 928081 $ $Date: 2010-03-26 18:36:38 -0400 (Fri, 26 Mar 2010) $
 * @since 2.0
 */
public interface SingularValueDecomposition {

    /**
     * Returns the matrix U of the decomposition.
     * <p>U is an orthogonal matrix, i.e. its transpose is also its inverse.

* @return the U matrix * @see #getUT() */ RealMatrix getU(); /** * Returns the transpose of the matrix U of the decomposition. * <p>U is an orthogonal matrix, i.e. its transpose is also its inverse.

* @return the U matrix (or null if decomposed matrix is singular) * @see #getU() */ RealMatrix getUT(); /** * Returns the diagonal matrix ? of the decomposition. * <p>? is a diagonal matrix. The singular values are provided in * non-increasing order, for compatibility with Jama.</p> * @return the ? matrix */ RealMatrix getS(); /** * Returns the diagonal elements of the matrix ? of the decomposition. * <p>The singular values are provided in non-increasing order, for * compatibility with Jama.</p> * @return the diagonal elements of the ? matrix */ double[] getSingularValues(); /** * Returns the matrix V of the decomposition. * <p>V is an orthogonal matrix, i.e. its transpose is also its inverse.

* @return the V matrix (or null if decomposed matrix is singular) * @see #getVT() */ RealMatrix getV(); /** * Returns the transpose of the matrix V of the decomposition. * <p>V is an orthogonal matrix, i.e. its transpose is also its inverse.

* @return the V matrix (or null if decomposed matrix is singular) * @see #getV() */ RealMatrix getVT(); /** * Returns the n × n covariance matrix. * <p>The covariance matrix is V × J × VT * where J is the diagonal matrix of the inverse of the squares of * the singular values.</p> * @param minSingularValue value below which singular values are ignored * (a 0 or negative value implies all singular value will be used) * @return covariance matrix * @exception IllegalArgumentException if minSingularValue is larger than * the largest singular value, meaning all singular values are ignored */ RealMatrix getCovariance(double minSingularValue) throws IllegalArgumentException; /** * Returns the L<sub>2 norm of the matrix. * <p>The L2 norm is max(|A × u|2 / * |u|<sub>2), where |.|2 denotes the vectorial 2-norm * (i.e. the traditional euclidian norm).</p> * @return norm */ double getNorm(); /** * Return the condition number of the matrix. * @return condition number of the matrix */ double getConditionNumber(); /** * Return the effective numerical matrix rank. * <p>The effective numerical rank is the number of non-negligible * singular values. The threshold used to identify non-negligible * terms is max(m,n) × ulp(s<sub>1) where ulp(s1) * is the least significant bit of the largest singular value.</p> * @return effective numerical matrix rank */ int getRank(); /** * Get a solver for finding the A × X = B solution in least square sense. * @return a solver */ DecompositionSolver getSolver(); }

Other Commons Math examples (source code examples)

Here is a short list of links related to this Commons Math SingularValueDecomposition.java source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.