matrix :: NativeDoubleArray :: in_buffer
matrix :: NativeDoubleArray :: mul
matrix :: NativeDoubleArray :: new
matrix $ NativeDoubleArray :: SELF
Type of this instance, automatically specialized in every classcore :: Pointer :: address_is_null
Is the address behind this Object at NULL?core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
core :: Object :: defaultinit
core :: Pointer :: defaultinit
matrix :: NativeDoubleArray :: in_buffer
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
matrix :: NativeDoubleArray :: mul
core :: Object :: native_class_name
The class name of the object in CString format.core :: Pointer :: native_equals
matrix :: NativeDoubleArray :: new
core :: Object :: output_class_name
Display class name on stdout (debug only).core :: Pointer :: premultiply_alpha
Multiply RGB values by their alpha value
# Specialized native structure to store matrix items and avoid boxing cost
private extern class NativeDoubleArray `{ double* `}
new(size: Int) do
var sizeof_double = 8
var buf = new CString(sizeof_double*size)
return new NativeDoubleArray.in_buffer(buf)
end
new in_buffer(buffer: CString) `{ return (double*)buffer; `}
fun [](i: Int): Float `{ return self[i]; `}
fun []=(i: Int, value: Float) `{ self[i] = value; `}
fun equal_items(other: NativeDoubleArray, len: Int): Bool `{
int i;
for (i = 0; i < len; i ++)
if (self[i] != other[i])
return 0;
return 1;
`}
fun hash_items(len: Int): Int `{
// Adapted from `SequenceRead::hash`
long r = 17+len;
int i;
for (i = 0; i < len; i ++)
r = r * 3 / 2 + (long)(i*1024.0);
return r;
`}
fun mul(a, b: NativeDoubleArray, a_width, a_height, b_width: Int) `{
int i, j, k;
for (j = 0; j < a_height; j ++)
for (i = 0; i < b_width; i ++) {
float sum = 0.0;
for (k = 0; k < a_width; k ++) sum += a[j*a_width + k] * b[k*b_width + i];
self[j*b_width + i] = sum;
}
`}
end
lib/matrix/matrix.nit:301,1--342,3
redef class NativeDoubleArray
fun mat4_set(f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15: Float) `{
self[ 0] = f0;
self[ 1] = f1;
self[ 2] = f2;
self[ 3] = f3;
self[ 4] = f4;
self[ 5] = f5;
self[ 6] = f6;
self[ 7] = f7;
self[ 8] = f8;
self[ 9] = f9;
self[10] = f10;
self[11] = f11;
self[12] = f12;
self[13] = f13;
self[14] = f14;
self[15] = f15;
`}
end
lib/matrix/projection.nit:197,1--219,3