lua.wetgenes.tardis.array
Array is the base class for all other tardis classes, it is just a stream of numbers, probably in a table but possibly a chunk of f32 values in a userdata.
lua.wetgenes.tardis.array.__add
r = array.__add(a,b)
Add a to b and return a a.new(result) so the class returned will match the input class of a and neither a or b will be modified.
lua.wetgenes.tardis.array.__div
r = array.__div(a,b)
Replace b with 1/b and then call the appropriate product function depending on the argument classes. Always creates and returns a.new() value.
lua.wetgenes.tardis.array.__eq
r = array.__eq(a,b)
meta to call a:compare(b) and return the result
lua.wetgenes.tardis.array.__mul
r = array.__mul(a,b)
Call the appropriate product function depending on the argument classes. Always creates and returns a.new() value.
lua.wetgenes.tardis.array.__sub
r = array.__sub(a,b)
Subtract b from a and return a a.new(result) so the class returned will match the input class of a and neither a or b will be modified.
lua.wetgenes.tardis.array.__tostring
string = array.__tostring(it)
Convert an array to a string this is called by the lua tostring() function,
lua.wetgenes.tardis.array.__unm
r = array.__unm(a)
Subtract b from 0 and return a a.new(result) so the class returned will match the input class of a but a will not be modified
lua.wetgenes.tardis.array.abs
r=it:abs(r)
r=it:abs(it.new())
Perform math.abs on all values of this array.
If r is provided then the result is written into r and returned otherwise it is modified and returned.
lua.wetgenes.tardis.array.acos
r=it:acos(r)
r=it:acos(it.new())
Perform math.acos on all values of this array.
If r is provided then the result is written into r and returned otherwise it is modified and returned.
lua.wetgenes.tardis.array.add
r=it:add(b,r)
r=it:add(b,it.new())
Add b to it. b may be a number or another array of the same size as this array.
If r is provided then the result is written into r and returned otherwise it is modified and returned.
lua.wetgenes.tardis.array.asin
r=it:asin(r)
r=it:asin(it.new())
Perform math.asin on all values of this array.
If r is provided then the result is written into r and returned otherwise it is modified and returned.
lua.wetgenes.tardis.array.atan
r=it:atan(r)
r=it:atan(it.new())
Perform math.atan on all values of this array.
If r is provided then the result is written into r and returned otherwise it is modified and returned.
lua.wetgenes.tardis.array.ceil
r=it:ceil(r)
r=it:ceil(it.new())
Perform math.ceil on all values of this array.
If r is provided then the result is written into r and returned otherwise it is modified and returned.
lua.wetgenes.tardis.array.compare
a=a:compare(b)
a=a:compare(1,2,3,4)
Are the numbers in b the same as the numbers in a, this function will return true if they are and false if they are not.
If the arrays are of different lengths then this will return false.
Numbers to test for can be given explicitly in the arguments and we follow the same one level of tables rule as we do with array.set so any class derived from array can be used.
lua.wetgenes.tardis.array.cos
r=it:cos(r)
r=it:cos(it.new())
Perform math.cos on all values of this array.
If r is provided then the result is written into r and returned otherwise it is modified and returned.
lua.wetgenes.tardis.array.exp
r=it:exp(r)
r=it:exp(it.new())
Perform math.exp on all values of this array.
If r is provided then the result is written into r and returned otherwise it is modified and returned.
lua.wetgenes.tardis.array.floor
r=it:floor(r)
r=it:floor(it.new())
Perform math.floor on all values of this array.
If r is provided then the result is written into r and returned otherwise it is modified and returned.
lua.wetgenes.tardis.array.fract
r=it:fract(r)
r=it:fract(it.new())
Return the fractional part of each value using math.modf.
If r is provided then the result is written into r and returned otherwise it is modified and returned.
lua.wetgenes.tardis.array.log
r=it:log(r)
r=it:log(it.new())
Perform math.log on all values of this array.
If r is provided then the result is written into r and returned otherwise it is modified and returned.
lua.wetgenes.tardis.array.max
r=it:max()
Return a single number value that is the maximum of all values in this array.
lua.wetgenes.tardis.array.min
r=it:min()
Return a single number value that is the minimum of all values in this array.
lua.wetgenes.tardis.array.mix
r=a:mix(b,s,r)
Mix values between a and b where a is returned if s=0 and b is returned if s=1
If r is provided then the result is written into r and returned otherwise a is modified and returned.
lua.wetgenes.tardis.array.pow
r=it:pow(p,r)
r=it:pow(p,it.new())
Perform math.pow(it,p) on all values of this array. p may be a number or another array of the same size as this array.
If r is provided then the result is written into r and returned otherwise it is modified and returned.
lua.wetgenes.tardis.array.product
ma = ma:product(mb)
ma = ma:product(mb,r)
Look at the type and call the appropriate product function, to produce
mb x ma
Note the right to left application and default returning of the leftmost term for chaining. This seems to make the most sense.
If r is provided then the result is written into r and returned otherwise ma is modified and returned.
lua.wetgenes.tardis.array.quantize
r=it:quantize(1/1024,r)
r=it:quantize(s,it.new())
Perform a trunc(v/s)*s on all values of this array. We recomended the use of a power of two, eg 1/1024 rather than 1/1000 if you wanted 3 decimal digits.
If r is provided then the result is written into r and returned otherwise it is modified and returned.
lua.wetgenes.tardis.array.round
r=it:round(r)
r=it:round(it.new())
Perform math.floor( v+0.5 ) on all values of this array. Which will round up or down to the nearest integer.
If r is provided then the result is written into r and returned otherwise it is modified and returned.
lua.wetgenes.tardis.array.scalar
r=a:scalar(s,r)
Multiply all value in array by number.
If r is provided then the result is written into r and returned otherwise a is modified and returned.
lua.wetgenes.tardis.array.set
a=a:set(1,2,3,4)
a=a:set({1,2,3,4})
a=a:set({1,2},{3,4})
a=a:set(function(i) return i end)
Assign some numbers to an array, all the above examples will assign 1,2,3,4 to the first four slots in the given array, as you can see we allow one level of tables. Any class that is based on this array class can be used instead of an explicit table. So we can use a v2 or v3 or m4 etc etc.
if more numbers are given than the size of the array then they will be ignored.
if less numbers are given than the size of the array then the last number will be repeated.
if no numbers are given then nothing will be done
if a function is given it will be called with the index and should return a number.
lua.wetgenes.tardis.array.sin
r=it:sin(r)
r=it:sin(it.new())
Perform math.sin on all values of this array.
If r is provided then the result is written into r and returned otherwise it is modified and returned.
lua.wetgenes.tardis.array.sub
r=it:sub(b,r)
r=it:sub(b,it.new())
Subtract b from it. b may be a number or another array of the same size as this array.
If r is provided then the result is written into r and returned otherwise it is modified and returned.
lua.wetgenes.tardis.array.tan
r=it:tan(r)
r=it:tan(it.new())
Perform math.tan on all values of this array.
If r is provided then the result is written into r and returned otherwise it is modified and returned.
lua.wetgenes.tardis.array.trunc
r=it:trunc(r)
r=it:trunc(it.new())
Perform math.floor on positive values and math ceil on negative values for all values of this array. So a trunication that will always error towards 0.
If r is provided then the result is written into r and returned otherwise it is modified and returned.
lua.wetgenes.tardis.array.unpack
a1,a2=v2:unpack()
a1,a2,a3=v3:unpack()
a1,a2,a3,a4=v4:unpack()
Return all values in this array. Note this should be used instead of the unpack function for future optimisation safety.
lua.wetgenes.tardis.array.zero
a=a:zero()
Set all values in this array to zero.