Skip to content

An Objective-C class that performs basic Linear Algebra Matrix operations.

License

Notifications You must be signed in to change notification settings

pedrovieira/PVAlgebraMatrix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

PVAlgebraMatrix

An Objective-C class that performs basic Linear Algebra Matrix (learn more here) operations, such as:

  • Addition
  • Subtraction
  • Multiplication
  • Multiplication by a scalar
  • Transposition

Why I did this?

I've been teaching myself Objective-C since I was 15 and recently I entered university to study Computer Science. Among all the available subjects, the one that I'm liking the most (besides programming) is Linear Algebra and Analytic Geometry so I decided to combine my Objective-C skills with what I'm learning in university and try to simulate an Algebra Matrix class.

Features

General Features:
This class was designed to work somewhat like a NSArray, in terms of how you perform certain operations, so you can do stuff like:

  • Retrieve the number of rows / columns of the matrix (like you would do with NSArray's count)
  • Add/Insert a new row/columm
  • Remove a row/column
  • Retrieve an entire row/column (in a NSArray)
  • Retrieve an element from the matrix (at a specific row and column)
  • Replace a especific element with a new one

Specific Linear Algebra Matrix Features:

  • Retrieve the main diagonal elements (in a NSArray)
  • Check if the matrix is a Row / Column vector
  • Check if the matrix is a Null / Empty / Square / Identity / Diagonal / Triangular matrix
  • Check if two matrices are equal

How to use

  1. Add both .h and .m files of PVAlgebraMatrix into your project.
  2. Import PVAlgebraMatrix.h to wherever you want to use it just by #import "PVAlgebraMatrix.h"
  3. You're ready to start creating your own Matrices and kickass!

Creating Matrices

There are several ways of creating Matrices. You could just "alloc init" a PVAlgebraMatrix object to create an empty Matrix (0 rows and columns, with no elements) and add rows / columns as you wish, or you could create a default Matrix type (Identity or Null) in just one line of code.

Identity Matrix:

PVAlgebraMatrix *identityMatrix = [PVAlgebraMatrix identityMatrixWithSize:5];

Null Matrix:

PVAlgebraMatrix *nullMatrix = [PVAlgebraMatrix nullMatrixWithRows:5 columns:5];

Matrix with a default value for all the elements:

PVAlgebraMatrix *defaultValuesMatrix = [[PVAlgebraMatrix alloc] initWithRows:4 columns:5 setDefaultValueForAllElements:5];

Custom Matrix:

PVAlgebraMatrix *customMatrix = [[PVAlgebraMatrix alloc] init];
[customMatrix addRowFromArray:@[@2,@3,@4]];
[customMatrix addRowFromArray:@[@5,@6,@7]];
[customMatrix addRowFromArray:@[@8,@9,@0]];
[customMatrix addColumnFromArray:@[@1,@1,@1]];

Author

PVAlgebraMatrix was created by Pedro Vieira.
@w1tch_
[email protected]

License

Check "LICENSE" to know more.

About

An Objective-C class that performs basic Linear Algebra Matrix operations.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published