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

org.apfloat.spi.MatrixStrategy Maven / Gradle / Ivy

/*
 * MIT License
 *
 * Copyright (c) 2002-2023 Mikko Tommila
 *
 * 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.apfloat.spi;

import org.apfloat.ApfloatRuntimeException;

/**
 * Matrix operations.
 *
 * @since 1.7.0
 * @version 1.7.0
 * @author Mikko Tommila
 */

public interface MatrixStrategy
{
    /**
     * Transpose a n1 x n2 matrix.

* * Both n1 and n2 must be powers of two. * Additionally, one of these must be true:

* * n1 = n2
* n1 = 2*n2
* n2 = 2*n1
* * @param arrayAccess Accessor to the matrix data. This data will be transposed. * @param n1 Number of rows in the matrix. * @param n2 Number of columns in the matrix. */ public void transpose(ArrayAccess arrayAccess, int n1, int n2) throws ApfloatRuntimeException; /** * Transpose a square n1 x n1 block of n1 x n2 matrix.

* * Both n1 and n2 must be powers of two, * and n1 <= n2. * * @param arrayAccess Accessor to the matrix data. This data will be transposed. * @param n1 Number of rows and columns in the block to be transposed. * @param n2 Number of columns in the matrix. */ public void transposeSquare(ArrayAccess arrayAccess, int n1, int n2) throws ApfloatRuntimeException; /** * Permute the rows of the n1 x n2 matrix so that it is shaped like a * n1/2 x 2*n2 matrix. Logically, the matrix is split in half, and the * lower half is moved to the right side of the upper half.

* * Both n1 and n2 must be powers of two, * and n1 >= 2.

* * E.g. if the matrix layout is originally as follows: *

* * * * * * * * * * * * * *
Matrix before
0123
4567
891011
12131415
*

* * Then after this method it is as follows: *

* * * * * * * *
Matrix after
0123891011
456712131415
* * @param arrayAccess Accessor to the matrix data. This data will be permuted. * @param n1 Number of rows in the matrix. * @param n2 Number of columns in the matrix. * * @since 1.7.0 */ public void permuteToDoubleWidth(ArrayAccess arrayAccess, int n1, int n2) throws ApfloatRuntimeException; /** * Permute the rows of the n1 x n2 matrix so that it is shaped like a * 2*n1 x n2/2 matrix. Logically, the matrix is split in half, and the * right half is moved below the left half.

* * Both n1 and n2 must be powers of two. * * E.g. if the matrix layout is originally as follows: *

* * * * * * * *
Matrix before
01234567
89101112131415
*

* * Then after this method it is as follows: *

* * * * * * * * * * * * * *
Matrix after
0123
891011
4567
12131415
* * @param arrayAccess Accessor to the matrix data. This data will be permuted. * @param n1 Number of rows in the matrix. * @param n2 Number of columns in the matrix. */ public void permuteToHalfWidth(ArrayAccess arrayAccess, int n1, int n2) throws ApfloatRuntimeException; }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy