com.tagtraum.perf.datastructures
Class MatrixOperations

java.lang.Object
  |
  +--com.tagtraum.perf.datastructures.MatrixOperations

public class MatrixOperations
extends java.lang.Object

Operations for two dimensional int arrays.

Version:
$Id: $
Author:
Hendrik Schreiber

Constructor Summary
MatrixOperations()
           
 
Method Summary
static int[][] add(int[][] a, int[][] b)
          Adds two int matrices.
static int[][] add(int[][] a, int[][] b, int[][] c, int ax, int ay, int bx, int by, int cx, int cy, int rows, int columns)
          Adds two int sub-matrices.
static int[][] multiply(int[][] a, int[][] b)
          Multiplies two int matrices.
static int[][] multithreadedMultiply(int[][] a, int[][] b, int threads)
          Multiplies two int matrices.
static int[][] subtract(int[][] a, int[][] b)
          Substracts two int matrices.
static int[][] subtract(int[][] a, int[][] b, int[][] c, int ax, int ay, int bx, int by, int cx, int cy, int rows, int columns)
          Substracts two int sub-matrices.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MatrixOperations

public MatrixOperations()
Method Detail

add

public static int[][] add(int[][] a,
                          int[][] b)
Adds two int matrices.

Parameters:
a - matrix a
b - matrix b
Returns:
the resulting matrix

add

public static int[][] add(int[][] a,
                          int[][] b,
                          int[][] c,
                          int ax,
                          int ay,
                          int bx,
                          int by,
                          int cx,
                          int cy,
                          int rows,
                          int columns)
Adds two int sub-matrices.

Parameters:
a - matrix a
b - matrix b
c - resulting matrix
ax - starting row of the sub matrix in a that shall be used for the addition
ay - starting column of the sub matrix in a that shall be used for the addition
bx - starting row of the sub matrix in b that shall be used for the addition
by - starting column of the sub matrix in b that shall be used for the addition
cx - starting row of the sub matrix in c where the result shall be placed
cy - starting column of the sub matrix in a where the result shall be placed
rows - rows to add
columns - columns to add
Returns:
the resulting matrix
See Also:
add(int[][], int[][])

subtract

public static int[][] subtract(int[][] a,
                               int[][] b)
Substracts two int matrices.

Parameters:
a - matrix a
b - matrix b
Returns:
the resulting matrix

subtract

public static int[][] subtract(int[][] a,
                               int[][] b,
                               int[][] c,
                               int ax,
                               int ay,
                               int bx,
                               int by,
                               int cx,
                               int cy,
                               int rows,
                               int columns)
Substracts two int sub-matrices.

Parameters:
a - matrix a
b - matrix b
c - resulting matrix
ax - starting row of the sub matrix in a that shall be used for the substraction
ay - starting column of the sub matrix in a that shall be used for the substraction
bx - starting row of the sub matrix in b that shall be used for the substraction
by - starting column of the sub matrix in b that shall be used for the substraction
cx - starting row of the sub matrix in c where the result shall be placed
cy - starting column of the sub matrix in a where the result shall be placed
rows - rows to substract
columns - columns to substract
Returns:
the resulting matrix
See Also:
add(int[][], int[][])

multiply

public static int[][] multiply(int[][] a,
                               int[][] b)
Multiplies two int matrices. If this method is executed in a SMP environment, the number of available processors times 16 threads are started to compute the result concurrently. This methods is synchronous.

Parameters:
a - matrix a
b - matrix b
Returns:
the resulting matrix

multithreadedMultiply

public static int[][] multithreadedMultiply(int[][] a,
                                            int[][] b,
                                            int threads)
Multiplies two int matrices. Starts n threads to compute the result concurrently. This methods is synchronous.

Parameters:
a - matrix a
b - matrix b
threads - the number of threads to start. If threads is <=1 no separate thread is started
Returns:
the resulting matrix


Copyright © 2002 Hendrik Schreiber
http://www.tagtraum.com/performance/
This software can be distributed under LGPL