# Using JPythonMethod's matrix and FFT functions

May, 2001

## Introduction

(Note: in order to use these functions, you must install JAMA)

A large number of matrix manipulation functions are available for your use and are defined below). Each of these returns a Data object. To illustrate their use, here's a brief example:

```# first, construct a 2 x 2 matrix in a VisAD field
matrix = field( [[1,2], [1,3]])

# now construct a 2 element vector
vector = field([2,1])

# solve the linear system
solution = solve(matrix, vector)

# print the solution
print solution[0], solution[1]

# this will print: 4.0 -1.0
```

## Fast Fourier Transform (FFT)

• fft(field)
• ifft(field) // backward Fourier transform

## Matrix manipulation routines

• chol(Data d) - return matrix Cholesky Decomposition of Data d
• cond(Data d) - return matrix condition of data (ratio of largest to smallest singular value)
• det(Data d) - return matrix determinant of Data d
• eig(Data d) - return matrix Eigenvalue Decomposition of Data d
• inverse(Data d) - return matrix inverse of Data d
• lu(Data d) - return matrix LU Decomposition of Data d
• matrixMultiply(data1, data2) - return matrix multiply of (data1 * data2)
• norm1(Data d) - return matrix one norm of data (maximum column sum)
• norm2(Data d) - return matrix two norm of data (maximum singular value)
• normF(Data d) - return matrix Frobenius norm of data (sqrt of sum of squares of all elements)
• normInf(Data d) - return matrix infinity norm of data (maximum row sum)
• qr(Data d) - return matrix QR Decomposition of data
• rank(Data d) - return matrix effective numerical rank (from SVD) of data
• solve(Data d1, Data d2) - return matrix soluton X of (d1 * X = d2)
• svd(Data d) - return matrix Singular Value Decomposition of data
• trace(Data d) - return matrix trace of data (sum of the diagonal elements)
• transpose(Data d) - return matrix transpose of data