BGBDY_API mat4 dtyMat4Add(mat4 a, mat4 b) { mat4 c; vfvec4(c.v+ 0, v4add(vec4vf(a.v+ 0), vec4vf(b.v+ 0))); vfvec4(c.v+ 4, v4add(vec4vf(a.v+ 4), vec4vf(b.v+ 4))); vfvec4(c.v+ 8, v4add(vec4vf(a.v+ 8), vec4vf(b.v+ 8))); vfvec4(c.v+12, v4add(vec4vf(a.v+12), vec4vf(b.v+12))); #if 0 c.v[ 0]=a.v[ 0]+b.v[ 0]; c.v[ 1]=a.v[ 1]+b.v[ 1]; c.v[ 2]=a.v[ 2]+b.v[ 2]; c.v[ 3]=a.v[ 3]+b.v[ 3]; c.v[ 4]=a.v[ 4]+b.v[ 4]; c.v[ 5]=a.v[ 5]+b.v[ 5]; c.v[ 6]=a.v[ 6]+b.v[ 6]; c.v[ 7]=a.v[ 7]+b.v[ 7]; c.v[ 8]=a.v[ 8]+b.v[ 8]; c.v[ 9]=a.v[ 9]+b.v[ 9]; c.v[10]=a.v[10]+b.v[10]; c.v[11]=a.v[11]+b.v[11]; c.v[12]=a.v[12]+b.v[12]; c.v[13]=a.v[13]+b.v[13]; c.v[14]=a.v[14]+b.v[14]; c.v[15]=a.v[15]+b.v[15]; #endif return(c); }
/* ========================================================================= */ local inline unsigned long vector_chop(unsigned long x) { unsigned long y; y = v4shl(x, 16); y = v4shru(y, 16); x = v4shru(x, 16); y = v4sub(y, x); x = v4shl(x, 4); x = v4add(x, y); return x; }
BGBDY_API mat2 dtyMat2Add(mat2 a, mat2 b) { mat2 c; vfvec4(c.v, v4add(vec4vf(a.v), vec4vf(b.v))); // c.v[0]=a.v[0]+b.v[0]; // c.v[1]=a.v[1]+b.v[1]; // c.v[2]=a.v[2]+b.v[2]; // c.v[3]=a.v[3]+b.v[3]; return(c); }
BGBDY_API mat3 dtyMat3Add(mat3 a, mat3 b) { mat3 c; vfvec4(c.v+0, v4add(vec4vf(a.v+0), vec4vf(b.v+0))); vfvec4(c.v+4, v4add(vec4vf(a.v+4), vec4vf(b.v+4))); vfvec4(c.v+8, v4add(vec4vf(a.v+8), vec4vf(b.v+8))); #if 0 c.v[ 0]=a.v[ 0]+b.v[ 0]; c.v[ 1]=a.v[ 1]+b.v[ 1]; c.v[ 2]=a.v[ 2]+b.v[ 2]; c.v[ 4]=a.v[ 4]+b.v[ 4]; c.v[ 5]=a.v[ 5]+b.v[ 5]; c.v[ 6]=a.v[ 6]+b.v[ 6]; c.v[ 8]=a.v[ 8]+b.v[ 8]; c.v[ 9]=a.v[ 9]+b.v[ 9]; c.v[10]=a.v[10]+b.v[10]; #endif return(c); }
BGBDY_API mat2 dtyMat2Mul(mat2 a, mat2 b) { vec4 a0, a1, b0, b1, t; mat2 c; t=vec4vf(a.v); a0=v4shuf(t, 0xA0); a1=v4shuf(t, 0xF5); t=vec4vf(b.v); b0=v4shuf(t, 0x44); b1=v4shuf(t, 0x66); t=v4add(v4mul(a0, b0), v4mul(a1, b1)); vfvec4(c.v, t); // c.v[0]=a.v[0]*b.v[0]+a.v[1]*b.v[2]; // c.v[1]=a.v[0]*b.v[1]+a.v[1]*b.v[3]; // c.v[2]=a.v[2]*b.v[0]+a.v[3]*b.v[2]; // c.v[3]=a.v[2]*b.v[1]+a.v[3]*b.v[3]; return(c); }