Melee Modding Library  2.0.0
A C library for modding Super Smash Bros Melee
Data Structures | Macros | Functions | Variables
matrix.h File Reference

Support for matrix and vector operations. More...

#include "gctypes.h"

Go to the source code of this file.

Data Structures

struct  Vector
 A vector of 32-bit floating-point values. More...
 
struct  Matrix
 A matrix of 32-bit floating-point values. More...
 

Macros

#define ROW_VECTOR(mat, ndx)   ((Vector) {mat.data[ndx], mat.nCol})
 

Functions

bool initVector (Vector *vec, size_t size)
 Initialize a Vector. More...
 
bool initMatrix (Matrix *mat, size_t numRows, size_t numCols)
 Initialize a matrix. More...
 
void populateVec (Vector *vec, void *func)
 Populate the values in a vector. More...
 
void populateMat (Matrix *mat, void *func)
 Populate the values in a matrix. More...
 
void matrixVectorProduct (Vector *y, const Matrix *A, const Vector *x)
 Multiplication of the form y = Ax More...
 
float vectorDotProd (const Vector *u, const Vector *v)
 Calculates the dot product of two vectors. More...
 

Variables

bool _matrixError
 Set to true when a error occurs in a matrix operation.
 

Detailed Description

Support for matrix and vector operations.


Data Structure Documentation

struct Vector

A vector of 32-bit floating-point values.

Data Fields
float * data

array of floating-point values

size_t size

size of data

struct Matrix

A matrix of 32-bit floating-point values.

Data Fields
float ** data

two-dimensional array of floating-point values

size_t nRow

number of rows in the matrix

size_t nCol

number of columns in the matrix

Macro Definition Documentation

#define ROW_VECTOR (   mat,
  ndx 
)    ((Vector) {mat.data[ndx], mat.nCol})

Extract a row from mat as a Vector struct

Function Documentation

void populateVec ( Vector vec,
void *  func 
)

Populate the values in a vector.

This function populates each element in the vector based on func. Element n will be equal to func(n) .

Parameters
vec- pointer to a Vector struct
func- pointer to a function of the form float foo(u32)
Returns
None.
void populateMat ( Matrix mat,
void *  func 
)

Populate the values in a matrix.

This function populates each element in the matrix based on func. The element at [row][col] will be equal to func(row, col) .

Parameters
mat- pointer to a Matrix struct
func- pointer to a function of the form float foo(u32, u32)
Returns
None.
void matrixVectorProduct ( Vector y,
const Matrix A,
const Vector x 
)

Multiplication of the form y = Ax

This function multiplies Ax and stores the result in y.

Parameters
y- pointer to Vector struct
A- pointer to Matrix struct
x- pointer to Vector struct
Returns
none
Note
This function uses specific optimizations for the Wii hardware
See also
http://wiibrew.org/wiki/Paired_single
float vectorDotProd ( const Vector u,
const Vector v 
)

Calculates the dot product of two vectors.

Parameters
u- pointer to a Vector struct
v- pointer to a Vector struct
Returns
The standard dot product of u and v.
Note
This function uses specific optimizations for the Wii hardware
See also
http://wiibrew.org/wiki/Paired_single