//----------------------------------------------------------------------------- // Project GeometryKit // Class G3DMatrix // Creator Philippe C.D. Robert // Maintainer Philippe C.D. Robert // Creation Date Thu Sep 9 11:05:08 CEST 1999 // // Copyright (c) Philippe C.D. Robert // // The GeometryKit is free software; you can redistribute it and/or modify it // under the terms of the GNU LGPL Version 2 as published by the Free // Software Foundation // // $Id: G3DMatrix.h,v 1.6 2001/01/05 20:50:48 robert Exp $ //----------------------------------------------------------------------------- #ifndef __G3DMatrix_h_INCLUDE #define __G3DMatrix_h_INCLUDE #import @class G3DVector; @interface G3DMatrix : NSObject { double *matrix; int _rows; int _columns; } //----------------------------------------------------------------------------- // class methods //----------------------------------------------------------------------------- + (G3DMatrix *)matrixWithRows:(int)rows columns:(int)cols; + (G3DMatrix *)matrixWithRows:(int)rows columns:(int)cols elements:(double *)vals; + (G3DMatrix *)matrixWithMatrix:(G3DMatrix *)aMatrix; //----------------------------------------------------------------------------- // init and free //----------------------------------------------------------------------------- - (id)initWithRows:(int)rows columns:(int)cols; - (id)initWithRows:(int)rows columns:(int)cols elements:(double *)vals; - (id)initWithMatrix:(G3DMatrix *)aMatrix; - (void)dealloc; //----------------------------------------------------------------------------- // math //----------------------------------------------------------------------------- - (void)addMatrix:(G3DMatrix *)a; - (void)addMatrix:(G3DMatrix *)a plus:(G3DMatrix *)b; - (void)subMatrix:(G3DMatrix *)a; - (void)subMatrix:(G3DMatrix *)a minus:(G3DMatrix *)b; - (void)multiplyByMatrix:(G3DMatrix *)a; - (void)multiplyByMatrix:(G3DMatrix *)a with:(G3DMatrix *)b; - (void)multiplyByMatrix:(G3DMatrix *)a withTransposed:(G3DMatrix *)b; - (void)multiplyByTransposedMatrix:(G3DMatrix *)a with:(G3DMatrix *)b; - (void)multiplyByTransposedMatrix:(G3DMatrix *)a withTransposed:(G3DMatrix *)b; - (void)invert; - (G3DMatrix *)invertedMatrix; - (void)adjoint; - (G3DMatrix *)adjointedMatrix; - (void)transpose; - (G3DMatrix *)transposedMatrix; - (void)negate; - (G3DMatrix *)negatedMatrix; - (void)multiplyByScalar:(double)scalar; - (void)divideByScalar:(double)scalar; - (int)svdWithU:(G3DMatrix **)u W:(G3DMatrix **)w V:(G3DMatrix **)v; // Returns the rank of the matrix after doing a single value decomposition so that self = u * w * transpose(v) - (double)determinant; - (double)trace; - (int)rank; //----------------------------------------------------------------------------- // accessor methods //----------------------------------------------------------------------------- - (int)rows; - (int)columns; - (BOOL)isQuadratic; - (G3DVector *)rowVectorAtIndex:(int)n; - (G3DVector *)columnVectorAtIndex:(int)n; - (void)setIdentity; - (void)setZero; - (void)setMatrix:(G3DMatrix *)aMatrix; - (void)setElements:(double *)vals; - (void)setElement:(double)val atRow:(int)row column:(int)col; - (double)elementAtRow:(int)row column:(int)col; - (double *)elements; - (void)setElements:(double *)vals inRow:(int)row; - (void)setVector:(G3DVector *)vec inRow:(int)row; - (void)setElements:(double *)vals inColumn:(int)col; - (void)setVector:(G3DVector *)vec inColumn:(int)col; //----------------------------------------------------------------------------- // misc //----------------------------------------------------------------------------- - (BOOL)isEqualToMatrix:(G3DMatrix *)aMatrix; - (NSString *)description; //----------------------------------------------------------------------------- // NSCoding //----------------------------------------------------------------------------- - (void)encodeWithCoder:(NSCoder *)aCoder; - (id)initWithCoder:(NSCoder *)aCoder; //----------------------------------------------------------------------------- // NSCopying //----------------------------------------------------------------------------- - (id)copyWithZone:(NSZone *)zone; @end extern NSString *G3DMatrixException; #endif __G3DMatrix_h_INCLUDE