Fill elements.
Matrix multiply for vector.
Get an element.
Set an element.
operation and assign an element.
Operation and assign other vector.
Vector pointer.
immutable v = Vector!3([1, 2, 3]); assert(v[0].isClose(1.0)); assert(v[1].isClose(2.0)); assert(v[2].isClose(3.0));
auto v = Vector!3([1, 2, 3]); v[0] = 2.0f; v[1] = 3.0f; v[2] = 4.0f; assert(v[0].isClose(2.0)); assert(v[1].isClose(3.0)); assert(v[2].isClose(4.0)); v[0] += 1.0f; v[1] += 1.0f; v[2] += 1.0f; assert(v[0].isClose(3.0)); assert(v[1].isClose(4.0)); assert(v[2].isClose(5.0));
auto v = Vector!3([1, 2, 3]); immutable u = Vector!3([2, 3, 4]); v += u; assert(v[0].isClose(3.0)); assert(v[1].isClose(5.0)); assert(v[2].isClose(7.0));
import std.math : isNaN; Vector!3 v; assert(v[0].isNaN); assert(v[1].isNaN); assert(v[2].isNaN); immutable u = Vector!3([2, 3, 4]); foreach (i, e; u[]) { v[i] = e; } assert(v[0].isClose(2.0)); assert(v[1].isClose(3.0)); assert(v[2].isClose(4.0));
import std.math : isNaN; Vector!3 v; v.fill(1.0); foreach (e; v[]) { assert(e.isClose(1.0)); }
immutable v = Vector!3([1, 2, 3]); assert(isClose(*(v.ptr), 1.0));
import std.math : isClose; immutable m = Matrix!(4, 4).unit; immutable v = Vector!4([1, 2, 3, 0]); auto result = Vector!4(); result.mul(m, v); assert(result == v);
import karasux.linear_algebra.vector : isClose; immutable m = Matrix!(4, 4).scale(2.0, 3.0, 4.0); immutable v = Vector!4([1, 2, 3, 0]); auto result = Vector!4(); result.mul(m, v); assert(result.isClose(Vector!4([2, 6, 12, 0])));
Vector structure.