Matrix 0.2
2 posters
RigidChips :: Rigid-Chips :: Files :: Scripts
Page 1 of 1
Matrix 0.2
So, this is the second version of my matrix library. As it is not completed yet, it is currently at 0.2. (here)
The library follows a principle opposite from that of DanielLC's library - no destructive function calls. So basically, if you call a function, you can be sure that it won't modify any variables except the one(s) you assign the result too. This differs from DanielLC's, where it modifies the matrix passed as an arguement to the function.
The library itself has descriptions of all the functions, but here's another list anyway.
Arithmetic functions: Addition/subtraction
Unary minus (negation)
Scaling - Scalar multiplication/division
Multiplaction - matrix by matrix
Inversion
Integral exponentiation Other functions: Concatenation (horizontal)
Sectioning and cutting
Identity matrix creation (via size or matching matrix)
Reduced row echelon form Equality checking
Printing/string conversion
The library also contains functions for operating on rows:
However, these functions were created mainly just for use within the library.
Metatable Use:
As this library now has metatable support, it makes sense to tell everyone how to use it.
To define a table as a matrix, you have to either call matrix(<table>), or matrix.new(<table>). Then, if you set these to variables you can use the normal arithmetic symbols.
A few notes:
So, feel free to use the library (with credit ), and if you think there are functions missing from it, please feel free to suggest them/edit them in.
.
Todo list:
Update log:
16-11-2010
27-11-2010
Object Orientation coming soon!
The library follows a principle opposite from that of DanielLC's library - no destructive function calls. So basically, if you call a function, you can be sure that it won't modify any variables except the one(s) you assign the result too. This differs from DanielLC's, where it modifies the matrix passed as an arguement to the function.
The library itself has descriptions of all the functions, but here's another list anyway.
- Dimension functions:
- Height
- Width
- Order
The library also contains functions for operating on rows:
- Addition/subtraction
- Negating
- Scalar multiplication/division
- Concatenation
- Sectioning
- Equality
- String conversion
However, these functions were created mainly just for use within the library.
Metatable Use:
As this library now has metatable support, it makes sense to tell everyone how to use it.
To define a table as a matrix, you have to either call matrix(<table>), or matrix.new(<table>). Then, if you set these to variables you can use the normal arithmetic symbols.
- Code:
m1 = matrix.new({{1,3},{2,4}})
m2 = matrix({3,1},{4,2})
result = (m2^-1+m1^2)*(m2^0*2)/6
A few notes:
- matrix()/matrix.new() accepts both a full table, and individual rows of the tables (See example)
So, feel free to use the library (with credit ), and if you think there are functions missing from it, please feel free to suggest them/edit them in.
.
Todo list:
- Object Orientation
- The library may include destructive calls later on, but they would all be identifiable.
Update log:
16-11-2010
- Added integral exponentiation
27-11-2010
- Added metatable support
Object Orientation coming soon!
Last edited by JHaskly on Sat Nov 27, 2010 5:10 am; edited 2 times in total
JHaskly- Admin
- Posts : 235
Join date : 2010-07-16
Age : 28
Location : Brisbane
Re: Matrix 0.2
I'm planning on modifying Jetcalc to use this once you add the metatable support stuff. I was going to just improve mine, but I figure it's good to have one standard that we all use.
DanielLC- Tank
- Posts : 78
Join date : 2010-10-23
Re: Matrix 0.2
I've got it modified, I'm just yet to upload it. Will do now.
The details are in the main post.
The details are in the main post.
JHaskly- Admin
- Posts : 235
Join date : 2010-07-16
Age : 28
Location : Brisbane
Re: Matrix 0.2
Can you do m1/m2? How about 1/m?
Have you checked to see if non-RigidChips lua programs work? It would be a shame for you to do all this and find out that we could have used Lua Matrix the whole time.
Have you checked to see if non-RigidChips lua programs work? It would be a shame for you to do all this and find out that we could have used Lua Matrix the whole time.
DanielLC- Tank
- Posts : 78
Join date : 2010-10-23
Re: Matrix 0.2
I haven't checked if Lua Matrix works, but I also did this as an exercise and a bit of a test for me
JHaskly- Admin
- Posts : 235
Join date : 2010-07-16
Age : 28
Location : Brisbane
Re: Matrix 0.2
And, 1/m is something I will pit in the next version, hopefully.
JHaskly- Admin
- Posts : 235
Join date : 2010-07-16
Age : 28
Location : Brisbane
Re: Matrix 0.2
I notice it doesn't have vectors. Are you going to add them in?
DanielLC- Tank
- Posts : 78
Join date : 2010-10-23
Re: Matrix 0.2
Perhaps at some point. If I need vectors I generally use Bwansy's vtr3 library.
JHaskly- Admin
- Posts : 235
Join date : 2010-07-16
Age : 28
Location : Brisbane
Re: Matrix 0.2
But you need to be able to multiply vectors by matrices.
DanielLC- Tank
- Posts : 78
Join date : 2010-10-23
RigidChips :: Rigid-Chips :: Files :: Scripts
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum