
org.ojalgo.matrix.decomposition.Tridiagonal Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ojalgo Show documentation
Show all versions of ojalgo Show documentation
oj! Algorithms - ojAlgo - is Open Source Java code that has to do with mathematics, linear algebra and optimisation.
The newest version!
/*
* Copyright 1997-2025 Optimatika
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.ojalgo.matrix.decomposition;
import org.ojalgo.matrix.store.MatrixStore;
import org.ojalgo.scalar.ComplexNumber;
import org.ojalgo.scalar.Quadruple;
import org.ojalgo.scalar.Quaternion;
import org.ojalgo.scalar.RationalNumber;
import org.ojalgo.structure.Access2D;
import org.ojalgo.type.context.NumberContext;
/**
* Tridiagonal: [A] = [Q][D][Q]H Any square symmetric (hermitian) matrix [A] can be factorized by
* similarity transformations into the form, [A]=[Q][D][Q]-1 where [Q] is an orthogonal (unitary)
* matrix and [D] is a real symmetric tridiagonal matrix. Note that [D] can/should be made real even when [A]
* has complex elements. Since [Q] is orthogonal (unitary) [Q]-1 = [Q]H and when it is
* real [Q]H = [Q]T.
*
* @author apete
*/
public interface Tridiagonal> extends MatrixDecomposition {
interface Factory> extends MatrixDecomposition.Factory> {
}
Factory C128 = typical -> new DeferredTridiagonal.C128();
Factory R064 = typical -> new DeferredTridiagonal.R064();
Factory R128 = typical -> new DeferredTridiagonal.R128();
Factory H256 = typical -> new DeferredTridiagonal.H256();
Factory Q128 = typical -> new DeferredTridiagonal.Q128();
static > boolean equals(final MatrixStore matrix, final Tridiagonal decomposition, final NumberContext context) {
boolean retVal = true;
// Check that [A] == [Q][D][Q]T
retVal &= Access2D.equals(matrix, decomposition.reconstruct(), context);
// Check that Q is orthogonal/unitary...
final MatrixStore mtrxQ = decomposition.getQ();
MatrixStore identity = mtrxQ.physical().makeEye(mtrxQ.countRows(), mtrxQ.countColumns());
MatrixStore qqh = mtrxQ.multiply(mtrxQ.conjugate());
retVal &= qqh.equals(identity, context);
MatrixStore qhq = mtrxQ.conjugate().multiply(mtrxQ);
retVal &= qhq.equals(identity, context);
return retVal;
}
MatrixStore getD();
MatrixStore getQ();
default MatrixStore reconstruct() {
MatrixStore mtrxQ = this.getQ();
MatrixStore mtrxD = this.getD();
return mtrxQ.multiply(mtrxD).multiply(mtrxQ.conjugate());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy