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

org.ejml.dense.row.CommonOps_MT_FDRM Maven / Gradle / Ivy

Go to download

A fast and easy to use dense and sparse matrix linear algebra library written in Java.

There is a newer version: 0.43.1
Show newest version
/*
 * Copyright (c) 2020, Peter Abeles. All Rights Reserved.
 *
 * This file is part of Efficient Java Matrix Library (EJML).
 *
 * Licensed 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.ejml.dense.row;

import javax.annotation.Generated;
import org.ejml.EjmlParameters;
import org.ejml.UtilEjml;
import org.ejml.data.FMatrix1Row;
import org.ejml.data.FMatrixRMaj;
import org.ejml.dense.row.misc.TransposeAlgs_MT_FDRM;
import org.ejml.dense.row.mult.MatrixMatrixMult_MT_FDRM;
import org.jetbrains.annotations.Nullable;

import static org.ejml.UtilEjml.reshapeOrDeclare;

/**
 * Functions from {@link CommonOps_FDRM} with concurrent implementations.
 *
 * @author Peter Abeles
 */
@Generated("org.ejml.dense.row.CommonOps_MT_DDRM")
public class CommonOps_MT_FDRM {
    /**
     * 

Performs the following operation:
*
* c = a * b
*
* cij = ∑k=1:n { aik * bkj} *

* * @param a The left matrix in the multiplication operation. Not modified. * @param b The right matrix in the multiplication operation. Not modified. * @param output Where the results of the operation are stored. Modified. */ public static T mult( T a, T b, @Nullable T output ) { output = reshapeOrDeclare(output, a, a.numRows, b.numCols); UtilEjml.checkSameInstance(a, output); UtilEjml.checkSameInstance(b, output); MatrixMatrixMult_MT_FDRM.mult_reorder(a, b, output); return output; } /** *

Performs the following operation:
*
* c = α * a * b
*
* cij = α ∑k=1:n { * aik * bkj} *

* * @param alpha Scaling factor. * @param a The left matrix in the multiplication operation. Not modified. * @param b The right matrix in the multiplication operation. Not modified. * @param output Where the results of the operation are stored. Modified. */ public static T mult( float alpha, T a, T b, @Nullable T output ) { output = reshapeOrDeclare(output, a, a.numRows, b.numCols); UtilEjml.checkSameInstance(a, output); UtilEjml.checkSameInstance(b, output); MatrixMatrixMult_MT_FDRM.mult_reorder(alpha, a, b, output); return output; } /** *

Performs the following operation:
*
* c = aT * b
*
* cij = ∑k=1:n { aki * bkj} *

* * @param a The left matrix in the multiplication operation. Not modified. * @param b The right matrix in the multiplication operation. Not modified. * @param output Where the results of the operation are stored. Modified. */ public static T multTransA( T a, T b, @Nullable T output ) { output = reshapeOrDeclare(output, a, a.numCols, b.numCols); UtilEjml.checkSameInstance(a, output); UtilEjml.checkSameInstance(b, output); MatrixMatrixMult_MT_FDRM.multTransA_reorder(a, b, output); return output; } /** *

Performs the following operation:
*
* c = α * aT * b
*
* cij = α ∑k=1:n { aki * bkj} *

* * @param alpha Scaling factor. * @param a The left matrix in the multiplication operation. Not modified. * @param b The right matrix in the multiplication operation. Not modified. * @param output Where the results of the operation are stored. Modified. */ public static T multTransA( float alpha, T a, T b, @Nullable T output ) { output = reshapeOrDeclare(output, a, a.numCols, b.numCols); UtilEjml.checkSameInstance(a, output); UtilEjml.checkSameInstance(b, output); MatrixMatrixMult_MT_FDRM.multTransA_reorder(alpha, a, b, output); return output; } /** *

* Performs the following operation:
*
* c = a * bT
* cij = ∑k=1:n { aik * bjk} *

* * @param a The left matrix in the multiplication operation. Not modified. * @param b The right matrix in the multiplication operation. Not modified. * @param output Where the results of the operation are stored. Modified. */ public static T multTransB( T a, T b, @Nullable T output ) { output = reshapeOrDeclare(output, a, a.numRows, b.numRows); UtilEjml.checkSameInstance(a, output); UtilEjml.checkSameInstance(b, output); MatrixMatrixMult_MT_FDRM.multTransB(a, b, output); return output; } /** *

* Performs the following operation:
*
* c = α * a * bT
* cij = α ∑k=1:n { aik * bjk} *

* * @param alpha Scaling factor. * @param a The left matrix in the multiplication operation. Not modified. * @param b The right matrix in the multiplication operation. Not modified. * @param output Where the results of the operation are stored. Modified. */ public static T multTransB( float alpha, T a, T b, @Nullable T output ) { output = reshapeOrDeclare(output, a, a.numRows, b.numRows); UtilEjml.checkSameInstance(a, output); UtilEjml.checkSameInstance(b, output); MatrixMatrixMult_MT_FDRM.multTransB(alpha, a, b, output); return output; } /** *

* Performs the following operation:
*
* c = aT * bT
* cij = ∑k=1:n { aki * bjk} *

* * @param a The left matrix in the multiplication operation. Not modified. * @param b The right matrix in the multiplication operation. Not modified. * @param output Where the results of the operation are stored. Modified. */ public static T multTransAB( T a, T b, @Nullable T output ) { output = reshapeOrDeclare(output, a, a.numCols, b.numRows); UtilEjml.checkSameInstance(a, output); UtilEjml.checkSameInstance(b, output); MatrixMatrixMult_MT_FDRM.multTransAB(a, b, output); return output; } /** *

* Performs the following operation:
*
* c = α * aT * bT
* cij = α ∑k=1:n { aki * bjk} *

* * @param alpha Scaling factor. * @param a The left matrix in the multiplication operation. Not modified. * @param b The right matrix in the multiplication operation. Not modified. * @param output Where the results of the operation are stored. Modified. */ public static T multTransAB( float alpha, T a, T b, @Nullable T output ) { output = reshapeOrDeclare(output, a, a.numCols, b.numRows); UtilEjml.checkSameInstance(a, output); UtilEjml.checkSameInstance(b, output); MatrixMatrixMult_MT_FDRM.multTransAB(alpha, a, b, output); return output; } /** *

* Performs the following operation:
*
* c = c + a * b
* cij = cij + ∑k=1:n { aik * bkj} *

* * @param a The left matrix in the multiplication operation. Not modified. * @param b The right matrix in the multiplication operation. Not modified. * @param c Where the results of the operation are stored. Modified. */ public static void multAdd( FMatrix1Row a, FMatrix1Row b, FMatrix1Row c ) { MatrixMatrixMult_MT_FDRM.multAdd_reorder(a, b, c); } /** *

* Performs the following operation:
*
* c = c + α * a * b
* cij = cij + α * ∑k=1:n { aik * bkj} *

* * @param alpha scaling factor. * @param a The left matrix in the multiplication operation. Not modified. * @param b The right matrix in the multiplication operation. Not modified. * @param c Where the results of the operation are stored. Modified. */ public static void multAdd( float alpha, FMatrix1Row a, FMatrix1Row b, FMatrix1Row c ) { MatrixMatrixMult_MT_FDRM.multAdd_reorder(alpha, a, b, c); } /** *

* Performs the following operation:
*
* c = c + aT * b
* cij = cij + ∑k=1:n { aki * bkj} *

* * @param a The left matrix in the multiplication operation. Not modified. * @param b The right matrix in the multiplication operation. Not modified. * @param c Where the results of the operation are stored. Modified. */ public static void multAddTransA( FMatrix1Row a, FMatrix1Row b, FMatrix1Row c ) { MatrixMatrixMult_MT_FDRM.multAddTransA_reorder(a, b, c); } /** *

* Performs the following operation:
*
* c = c + α * aT * b
* cij =cij + α * ∑k=1:n { aki * bkj} *

* * @param alpha scaling factor * @param a The left matrix in the multiplication operation. Not modified. * @param b The right matrix in the multiplication operation. Not modified. * @param c Where the results of the operation are stored. Modified. */ public static void multAddTransA( float alpha, FMatrix1Row a, FMatrix1Row b, FMatrix1Row c ) { MatrixMatrixMult_MT_FDRM.multAddTransA_reorder(alpha, a, b, c); } /** *

* Performs the following operation:
*
* c = c + a * bT
* cij = cij + ∑k=1:n { aik * bjk} *

* * @param a The left matrix in the multiplication operation. Not modified. * @param b The right matrix in the multiplication operation. Not modified. * @param c Where the results of the operation are stored. Modified. */ public static void multAddTransB( FMatrix1Row a, FMatrix1Row b, FMatrix1Row c ) { MatrixMatrixMult_MT_FDRM.multAddTransB(a, b, c); } /** *

* Performs the following operation:
*
* c = c + α * a * bT
* cij = cij + α * ∑k=1:n { aik * bjk} *

* * @param alpha Scaling factor. * @param a The left matrix in the multiplication operation. Not modified. * @param b The right matrix in the multiplication operation. Not modified. * @param c Where the results of the operation are stored. Modified. */ public static void multAddTransB( float alpha, FMatrix1Row a, FMatrix1Row b, FMatrix1Row c ) { MatrixMatrixMult_MT_FDRM.multAddTransB(alpha, a, b, c); } /** *

* Performs the following operation:
*
* c = c + aT * bT
* cij = cij + ∑k=1:n { aki * bjk} *

* * @param a The left matrix in the multiplication operation. Not Modified. * @param b The right matrix in the multiplication operation. Not Modified. * @param c Where the results of the operation are stored. Modified. */ public static void multAddTransAB( FMatrix1Row a, FMatrix1Row b, FMatrix1Row c ) { MatrixMatrixMult_MT_FDRM.multAddTransAB(a, b, c); } /** *

* Performs the following operation:
*
* c = c + α * aT * bT
* cij = cij + α * ∑k=1:n { aki * bjk} *

* * @param alpha Scaling factor. * @param a The left matrix in the multiplication operation. Not Modified. * @param b The right matrix in the multiplication operation. Not Modified. * @param c Where the results of the operation are stored. Modified. */ public static void multAddTransAB( float alpha, FMatrix1Row a, FMatrix1Row b, FMatrix1Row c ) { MatrixMatrixMult_MT_FDRM.multAddTransAB(alpha, a, b, c); } /** *

Performs an "in-place" transpose.

* *

* For square matrices the transpose is truly in-place and does not require * additional memory. For non-square matrices, internally a temporary matrix is declared and * {@link #transpose(FMatrixRMaj, FMatrixRMaj)} is invoked. *

* * @param mat The matrix that is to be transposed. Modified. */ public static void transpose( FMatrixRMaj mat ) { if (mat.numCols == mat.numRows) { TransposeAlgs_MT_FDRM.square(mat); } else { FMatrixRMaj b = new FMatrixRMaj(mat.numCols, mat.numRows); transpose(mat, b); mat.setTo(b); } } /** *

* Transposes matrix 'a' and stores the results in 'b':
*
* bij = aji
* where 'b' is the transpose of 'a'. *

* * @param A The original matrix. Not modified. * @param A_tran Where the transpose is stored. If null a new matrix is created. Modified. * @return The transposed matrix. */ public static FMatrixRMaj transpose( FMatrixRMaj A, @Nullable FMatrixRMaj A_tran ) { A_tran = reshapeOrDeclare(A_tran, A.numCols, A.numRows); if (A.numRows > EjmlParameters.TRANSPOSE_SWITCH && A.numCols > EjmlParameters.TRANSPOSE_SWITCH) TransposeAlgs_MT_FDRM.block(A, A_tran, EjmlParameters.BLOCK_WIDTH); else TransposeAlgs_MT_FDRM.standard(A, A_tran); return A_tran; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy