Matrix 0.2

View previous topic View next topic Go down

Matrix 0.2

Post by JHaskly on Mon Nov 15, 2010 3:11 am

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.

  1. Dimension functions:
    • Height
    • Width
    • Order
  • 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:
    • 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 Razz ), 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

    _________________
    Previously (and currently) known as Juz.

    Please do not write "LUA", beause it's "Lua". It's Moon in Portuguese, not a Limited User Account, Last Universal Ancestor, or the Lukla Airport in Nepal.

    JHaskly
    Admin

    Posts : 235
    Join date : 2010-07-16
    Age : 21
    Location : Brisbane

    View user profile

    Back to top Go down

    Re: Matrix 0.2

    Post by DanielLC on Fri Nov 26, 2010 8:42 pm

    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
    Tank

    Posts : 78
    Join date : 2010-10-23

    View user profile

    Back to top Go down

    Re: Matrix 0.2

    Post by JHaskly on Sat Nov 27, 2010 4:44 am

    I've got it modified, I'm just yet to upload it. Will do now.

    The details are in the main post.

    _________________
    Previously (and currently) known as Juz.

    Please do not write "LUA", beause it's "Lua". It's Moon in Portuguese, not a Limited User Account, Last Universal Ancestor, or the Lukla Airport in Nepal.

    JHaskly
    Admin

    Posts : 235
    Join date : 2010-07-16
    Age : 21
    Location : Brisbane

    View user profile

    Back to top Go down

    Re: Matrix 0.2

    Post by DanielLC on Sat Nov 27, 2010 10:34 am

    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.

    DanielLC
    Tank
    Tank

    Posts : 78
    Join date : 2010-10-23

    View user profile

    Back to top Go down

    Re: Matrix 0.2

    Post by JHaskly on Sat Nov 27, 2010 4:56 pm

    I haven't checked if Lua Matrix works, but I also did this as an exercise and a bit of a test for me Razz

    _________________
    Previously (and currently) known as Juz.

    Please do not write "LUA", beause it's "Lua". It's Moon in Portuguese, not a Limited User Account, Last Universal Ancestor, or the Lukla Airport in Nepal.

    JHaskly
    Admin

    Posts : 235
    Join date : 2010-07-16
    Age : 21
    Location : Brisbane

    View user profile

    Back to top Go down

    Re: Matrix 0.2

    Post by JHaskly on Sat Nov 27, 2010 4:57 pm

    And, 1/m is something I will pit in the next version, hopefully.

    _________________
    Previously (and currently) known as Juz.

    Please do not write "LUA", beause it's "Lua". It's Moon in Portuguese, not a Limited User Account, Last Universal Ancestor, or the Lukla Airport in Nepal.

    JHaskly
    Admin

    Posts : 235
    Join date : 2010-07-16
    Age : 21
    Location : Brisbane

    View user profile

    Back to top Go down

    Re: Matrix 0.2

    Post by DanielLC on Thu Apr 07, 2011 7:52 pm

    I notice it doesn't have vectors. Are you going to add them in?

    DanielLC
    Tank
    Tank

    Posts : 78
    Join date : 2010-10-23

    View user profile

    Back to top Go down

    Re: Matrix 0.2

    Post by JHaskly on Fri Apr 08, 2011 12:28 am

    Perhaps at some point. If I need vectors I generally use Bwansy's vtr3 library.

    _________________
    Previously (and currently) known as Juz.

    Please do not write "LUA", beause it's "Lua". It's Moon in Portuguese, not a Limited User Account, Last Universal Ancestor, or the Lukla Airport in Nepal.

    JHaskly
    Admin

    Posts : 235
    Join date : 2010-07-16
    Age : 21
    Location : Brisbane

    View user profile

    Back to top Go down

    Re: Matrix 0.2

    Post by DanielLC on Fri Apr 08, 2011 11:18 am

    But you need to be able to multiply vectors by matrices.

    DanielLC
    Tank
    Tank

    Posts : 78
    Join date : 2010-10-23

    View user profile

    Back to top Go down

    Re: Matrix 0.2

    Post by JHaskly on Fri Apr 08, 2011 4:47 pm

    I guess so.

    _________________
    Previously (and currently) known as Juz.

    Please do not write "LUA", beause it's "Lua". It's Moon in Portuguese, not a Limited User Account, Last Universal Ancestor, or the Lukla Airport in Nepal.

    JHaskly
    Admin

    Posts : 235
    Join date : 2010-07-16
    Age : 21
    Location : Brisbane

    View user profile

    Back to top Go down

    Re: Matrix 0.2

    Post by Sponsored content


    Sponsored content


    Back to top Go down

    View previous topic View next topic Back to top

    - Similar topics

     
    Permissions in this forum:
    You cannot reply to topics in this forum