RigidChips
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Matrix 0.2

2 posters

Go down

Matrix 0.2 Empty Matrix 0.2

Post by JHaskly 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

    JHaskly
    Admin

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

    Back to top Go down

    Matrix 0.2 Empty Re: Matrix 0.2

    Post by DanielLC 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

    Back to top Go down

    Matrix 0.2 Empty Re: Matrix 0.2

    Post by JHaskly 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.

    JHaskly
    Admin

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

    Back to top Go down

    Matrix 0.2 Empty Re: Matrix 0.2

    Post by DanielLC 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

    Back to top Go down

    Matrix 0.2 Empty Re: Matrix 0.2

    Post by JHaskly 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

    JHaskly
    Admin

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

    Back to top Go down

    Matrix 0.2 Empty Re: Matrix 0.2

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

    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

    Back to top Go down

    Matrix 0.2 Empty Re: Matrix 0.2

    Post by DanielLC 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

    Back to top Go down

    Matrix 0.2 Empty Re: Matrix 0.2

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

    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

    Back to top Go down

    Matrix 0.2 Empty Re: Matrix 0.2

    Post by DanielLC 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

    Back to top Go down

    Matrix 0.2 Empty Re: Matrix 0.2

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

    I guess so.

    JHaskly
    Admin

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

    Back to top Go down

    Matrix 0.2 Empty Re: Matrix 0.2

    Post by Sponsored content


    Sponsored content


    Back to top Go down

    Back to top

    - Similar topics

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