Posted 10 September 2014 - 01:31 AM
If you do not know what a Matrix is, I would recommend this wikipedia page.
Download:
1.0
pastebin get aE66gE86
API Functions
matrix.create( length/tbl, width )
Creates and returns a matrix object.
If a length and width are specified, it creates a len x wid matrix full of 0s
If the length is a table, it will create an array from that table. Format for the table is as follows:
Object Functions
object:insert( a, b, value )
changes the value of the specified matrix value
object:draw( x, y )
draws the matrix on screen at the specified coordinates (Note: this needs improvement)
object:len()
returns the length of the matrix
object:wid()
returns the width of the matrix
object:getValue( a, b )
returns the value within the matrix or nil
object:transpose()
see this page
object:trace()
adds all the items in the matrix together and returns them (note: this is temporary, until I figure out actual tracing
Metamethods
The following are allowed:
I am open to suggestions about how to improve this, many of the matrix functions on wikipedia go way over my head, I'm only in Algebra II…
Download:
1.0
pastebin get aE66gE86
API Functions
matrix.create( length/tbl, width )
Creates and returns a matrix object.
If a length and width are specified, it creates a len x wid matrix full of 0s
If the length is a table, it will create an array from that table. Format for the table is as follows:
{ {1, 2, 3}, {4, 5, 6} }
1 2 3
4 5 6
Object Functions
object:insert( a, b, value )
changes the value of the specified matrix value
object:draw( x, y )
draws the matrix on screen at the specified coordinates (Note: this needs improvement)
object:len()
returns the length of the matrix
object:wid()
returns the width of the matrix
object:getValue( a, b )
returns the value within the matrix or nil
object:transpose()
see this page
object:trace()
adds all the items in the matrix together and returns them (note: this is temporary, until I figure out actual tracing
Metamethods
The following are allowed:
matrix * matrix
matrix * num
matrix / num
matrix + matrix
matrix - matrix
matrix == matrix
matrix > matrix
matrix < matrix
matrix ^ num --#this may be inaccurate, and probably shouldn't be possible
the following are prohibited:
matrix / matrix
matrix()
setmetatable( matrix, {} )
the following are edited:
getmetatabe( matrix ) --#contains __type only!
I am open to suggestions about how to improve this, many of the matrix functions on wikipedia go way over my head, I'm only in Algebra II…