int main() { { // splicing different containers typedef std::forward_list<T> C; for (int l = 0; l <= size_t2; ++l) { for (int p = 0; p <= size_t1; ++p) { C c1(std::begin(t1), std::end(t1)); C c2(t2, t2+l); c1.splice_after(next(c1.cbefore_begin(), p), std::move(c2)); testd(c1, p, l); } } } #if __cplusplus >= 201103L { // splicing different containers typedef std::forward_list<T, min_allocator<T>> C; for (int l = 0; l <= size_t2; ++l) { for (int p = 0; p <= size_t1; ++p) { C c1(std::begin(t1), std::end(t1)); C c2(t2, t2+l); c1.splice_after(next(c1.cbefore_begin(), p), std::move(c2)); testd(c1, p, l); } } } #endif }
mnist_dataset(const std::string& path, const bool out_of_n_coding = true){ std::cout << "Reading MNIST dataset..."<<std::flush; std::ifstream ftraind((path + "/train-images.idx3-ubyte").c_str(),std::ios::in | std::ios::binary); // image data std::ifstream ftrainl((path + "/train-labels.idx1-ubyte").c_str(),std::ios::in | std::ios::binary); // label data std::ifstream ftestd ((path + "/t10k-images.idx3-ubyte").c_str(),std::ios::in | std::ios::binary); // image data std::ifstream ftestl ((path + "/t10k-labels.idx1-ubyte").c_str(),std::ios::in | std::ios::binary); // label data assert(ftraind.is_open()); assert(ftrainl.is_open()); assert(ftestd.is_open()); assert(ftestl.is_open()); char buf[16]; ftraind.read(buf,16); ftrainl.read(buf, 8); ftestd.read(buf,16); ftestl.read(buf, 8); cuv::tensor<unsigned char,cuv::host_memory_space> traind(cuv::extents[60000][784]); cuv::tensor<unsigned char,cuv::host_memory_space> trainl(cuv::extents[60000]); cuv::tensor<unsigned char,cuv::host_memory_space> testd(cuv::extents[10000][784]); cuv::tensor<unsigned char,cuv::host_memory_space> testl(cuv::extents[10000]); ftraind.read((char*)traind.ptr(), traind.size()); assert(ftraind.good()); ftrainl.read((char*)trainl.ptr(), trainl.size()); assert(ftrainl.good()); ftestd.read((char*)testd.ptr(), testd.size()); assert(ftestd.good()); ftestl.read((char*)testl.ptr(), testl.size()); assert(ftestl.good()); train_data.resize(traind.shape()); test_data.resize(testd.shape()); convert(train_data , traind); // convert data type convert(test_data , testd); // convert data type if (out_of_n_coding){ train_labels.resize(cuv::extents[60000][10]); test_labels.resize(cuv::extents[10000][10]); train_labels = 0.f; test_labels = 0.f; for (unsigned int i = 0; i < trainl.size(); ++i){ train_labels(i, trainl[i]) = 1.f; } for (unsigned int i = 0; i < testl.size(); ++i){ test_labels(i, testl[i]) = 1.f; } } else { train_labels.resize(cuv::extents[60000]); test_labels.resize(cuv::extents[10000]); for (unsigned int i = 0; i < trainl.size(); ++i){ train_labels(i) = trainl[i]; } for (unsigned int i = 0; i < testl.size(); ++i){ test_labels(i) = testl[i]; } } //train_data = train_data[cuv::indices[cuv::index_range(0,5000)][cuv::index_range()]]; //train_labels = train_labels[cuv::indices[cuv::index_range(0,5000)][cuv::index_range()]]; binary = true; channels = 1; image_size = 28; std::cout << "done."<<std::endl; }
int main(int, char**) { { // splicing different containers typedef std::forward_list<T> C; for (int l = 0; l <= size_t2; ++l) { for (int p = 0; p <= size_t1; ++p) { C c1(std::begin(t1), std::end(t1)); C c2(t2, t2+l); c1.splice_after(next(c1.cbefore_begin(), p), std::move(c2)); testd(c1, p, l); } } } #if TEST_STD_VER >= 11 { // splicing different containers typedef std::forward_list<T, min_allocator<T>> C; for (int l = 0; l <= size_t2; ++l) { for (int p = 0; p <= size_t1; ++p) { C c1(std::begin(t1), std::end(t1)); C c2(t2, t2+l); c1.splice_after(next(c1.cbefore_begin(), p), std::move(c2)); testd(c1, p, l); } } } #endif return 0; }
int tc_libcxx_containers_forwardlist_ops_splice_after_range(void) { { // splicing different containers typedef std::forward_list<T> C; for (int f = 0; f <= size_t2+1; ++f) { for (int l = f; l <= size_t2+1; ++l) { for (int p = 0; p <= size_t1; ++p) { C c1(std::begin(t1), std::end(t1)); C c2(std::begin(t2), std::end(t2)); c1.splice_after(next(c1.cbefore_begin(), p), std::move(c2), next(c2.cbefore_begin(), f), next(c2.cbefore_begin(), l)); testd(c1, p, f, l); } } } // splicing within same container for (int f = 0; f <= size_t1+1; ++f) { for (int l = f; l <= size_t1; ++l) { for (int p = 0; p <= f; ++p) { C c1(std::begin(t1), std::end(t1)); c1.splice_after(next(c1.cbefore_begin(), p), std::move(c1), next(c1.cbefore_begin(), f), next(c1.cbefore_begin(), l)); tests(c1, p, f, l); } for (int p = l; p <= size_t1; ++p) { C c1(std::begin(t1), std::end(t1)); c1.splice_after(next(c1.cbefore_begin(), p), std::move(c1), next(c1.cbefore_begin(), f), next(c1.cbefore_begin(), l)); tests(c1, p, f, l); } } } } TC_SUCCESS_RESULT(); return 0; }
int main(int argc, char *argv[]) { printf("1..3\n"); test_invalid(0.0, 0.0); test_invalid(1.0, 0.0); test_invalid(INFINITY, 0.0); test_invalid(INFINITY, 1.0); test_invalid(-INFINITY, 1.0); test_invalid(NAN, 1.0); test_invalid(1.0, NAN); test(4, 4, 0, 1); test(0, 3.0, 0, 0); testd(0x1p-1074, 1, 0x1p-1074, 0); testf(0x1p-149, 1, 0x1p-149, 0); test(3.0, 4, -1, 1); test(3.0, -4, -1, -1); testd(275 * 1193040, 275, 0, 1193040); test(4.5 * 7.5, 4.5, -2.25, 8); /* we should get the even one */ testf(0x1.9044f6p-1, 0x1.ce662ep-1, -0x1.f109cp-4, 1); #if LDBL_MANT_DIG > 53 testl(-0x1.23456789abcdefp-2000L, 0x1.fedcba987654321p-2000L, 0x1.b72ea61d950c862p-2001L, -1); #endif printf("ok 1 - rem\n"); /* * The actual quotient here is 864062210.50000003..., but * double-precision division gets -8.64062210.5, which rounds * the wrong way. This test ensures that remquo() is smart * enough to get the low-order bit right. */ testd(-0x1.98260f22fc6dep-302, 0x1.fb3167c430a13p-332, 0x1.fb3165b82de72p-333, -864062211); /* Even harder cases with greater exponent separation */ test(0x1.fp100, 0x1.ep-40, -0x1.cp-41, 143165577); testd(-0x1.abcdefp120, 0x1.87654321p-120, -0x1.69c78ec4p-121, -63816414); printf("ok 2 - rem\n"); test(0x1.66666cp+120, 0x1p+71, 0.0, 1476395008); testd(-0x1.0000000000003p+0, 0x1.0000000000003p+0, -0.0, -1); testl(-0x1.0000000000003p+0, 0x1.0000000000003p+0, -0.0, -1); testd(-0x1.0000000000001p-749, 0x1.4p-1072, 0x1p-1074, -1288490189); testl(-0x1.0000000000001p-749, 0x1.4p-1072, 0x1p-1074, -1288490189); printf("ok 3 - rem\n"); return (0); }
void MnistDataSet<M>::read() { std::string path = "/home/local/datasets/MNIST"; ifstream ftraind((path + "/train-images.idx3-ubyte").c_str()); ifstream ftrainl((path + "/train-labels.idx1-ubyte").c_str()); ifstream ftestd ((path + "/t10k-images.idx3-ubyte").c_str()); ifstream ftestl ((path + "/t10k-labels.idx1-ubyte").c_str()); char buf[16]; ftraind.read(buf,16); ftrainl.read(buf, 8); ftestd.read(buf,16); ftestl.read(buf, 8); tensor<unsigned char, host_memory_space> traind(extents[n_trainData][n_dim]); tensor<unsigned char, host_memory_space> trainl(extents[n_trainData]); tensor<unsigned char, host_memory_space> testd(extents[n_testData][n_dim]); tensor<unsigned char, host_memory_space> testl(extents[n_testData]); ftraind.read((char*)traind.ptr(), traind.size()); assert(ftraind.good()); ftrainl.read((char*)trainl.ptr(), trainl.size()); assert(ftrainl.good()); ftestd.read((char*)testd.ptr(), testd.size()); assert(ftestd.good()); ftestl.read((char*)testl.ptr(), testl.size()); assert(ftestl.good()); tensor<unsigned char, M> train_d(extents[n_trainData][n_dim]); tensor<unsigned char, M> train_l(extents[n_trainData]); tensor<unsigned char, M> test_d(extents[n_testData][n_dim]); tensor<unsigned char, M> test_l(extents[n_testData]); train_d = traind; train_l = trainl; test_d = testd; test_l = testl; // conversion to float: convert(this->X_train, train_d); convert(this->Y_train, train_l); convert(this->X_test, test_d); convert(this->Y_test, test_l); }
int main(int, char**) { { // splicing different containers typedef std::forward_list<T> C; for (int f = 0; f <= size_t2+1; ++f) { for (int l = f; l <= size_t2+1; ++l) { for (int p = 0; p <= size_t1; ++p) { C c1(std::begin(t1), std::end(t1)); C c2(std::begin(t2), std::end(t2)); c1.splice_after(next(c1.cbefore_begin(), p), std::move(c2), next(c2.cbefore_begin(), f), next(c2.cbefore_begin(), l)); testd(c1, p, f, l); } } } // splicing within same container for (int f = 0; f <= size_t1+1; ++f) { for (int l = f; l <= size_t1; ++l) { for (int p = 0; p <= f; ++p) { C c1(std::begin(t1), std::end(t1)); c1.splice_after(next(c1.cbefore_begin(), p), std::move(c1), next(c1.cbefore_begin(), f), next(c1.cbefore_begin(), l)); tests(c1, p, f, l); } for (int p = l; p <= size_t1; ++p) { C c1(std::begin(t1), std::end(t1)); c1.splice_after(next(c1.cbefore_begin(), p), std::move(c1), next(c1.cbefore_begin(), f), next(c1.cbefore_begin(), l)); tests(c1, p, f, l); } } } } #if TEST_STD_VER >= 11 { // splicing different containers typedef std::forward_list<T, min_allocator<T>> C; for (int f = 0; f <= size_t2+1; ++f) { for (int l = f; l <= size_t2+1; ++l) { for (int p = 0; p <= size_t1; ++p) { C c1(std::begin(t1), std::end(t1)); C c2(std::begin(t2), std::end(t2)); c1.splice_after(next(c1.cbefore_begin(), p), std::move(c2), next(c2.cbefore_begin(), f), next(c2.cbefore_begin(), l)); testd(c1, p, f, l); } } } // splicing within same container for (int f = 0; f <= size_t1+1; ++f) { for (int l = f; l <= size_t1; ++l) { for (int p = 0; p <= f; ++p) { C c1(std::begin(t1), std::end(t1)); c1.splice_after(next(c1.cbefore_begin(), p), std::move(c1), next(c1.cbefore_begin(), f), next(c1.cbefore_begin(), l)); tests(c1, p, f, l); } for (int p = l; p <= size_t1; ++p) { C c1(std::begin(t1), std::end(t1)); c1.splice_after(next(c1.cbefore_begin(), p), std::move(c1), next(c1.cbefore_begin(), f), next(c1.cbefore_begin(), l)); tests(c1, p, f, l); } } } } #endif return 0; }
void TestApp::test_vector2(void) { Console::write_line(" Header: cl_vector.h"); Console::write_line(" Class: Vec2"); Console::write_line(" Function: rotate()"); { Vec2i test_a; Vec2i hotspot(1,3); test_a = Vec2i(4,5); test_a.rotate(hotspot, Angle(0, angle_degrees)); if (test_a != Vec2i(4, 5)) fail(); test_a = Vec2i(4,5); test_a.rotate(hotspot, Angle(90, angle_degrees)); if (test_a != Vec2i(-1, 6)) fail(); test_a = Vec2i(4,5); test_a.rotate(hotspot, Angle(180, angle_degrees)); if (test_a != Vec2i(-2, 1)) fail(); test_a = Vec2i(4,5); test_a.rotate(hotspot, Angle(270, angle_degrees)); if (test_a != Vec2i(3, 0)) fail(); test_a = Vec2i(4,5); test_a.rotate(hotspot, Angle(360, angle_degrees)); if (test_a != Vec2i(4, 5)) fail(); test_a = Vec2i(4,5); test_a.rotate(Vec2i(0,0), Angle(180, angle_degrees)); if (test_a != Vec2i(-4, -5)) fail(); } Console::write_line(" Function: distance()"); { Vec2d test_a(2.0,3.0); Vec2d test_b(3.0,4.0); if (test_a.distance(test_b) != sqrt(1.0 + 1.0 )) fail(); } Console::write_line(" Function: normalize()"); { Vec2d testi(3.0,4.0); testi.normalize(); if (testi != Vec2d(3.0/sqrt(25.0), 4.0/sqrt(25.0))) fail(); } Console::write_line(" Function: static normalize()"); { Vec2d testi(3.0,4.0); if (Vec2d::normalize(testi) != Vec2d(3.0/sqrt(25.0), 4.0/sqrt(25.0))) fail(); } Console::write_line(" Function: length()"); { Vec2d testi(3.0,4.0); if (testi.length() != sqrt(25.0 )) fail(); } Console::write_line(" Function: dot()"); { Vec2d test_a(3.0,4.0); Vec2d test_b(13.0,14.0); if (test_a.dot(test_b) != ((3.0 * 13.0)+ (4.0*14.0))) fail(); } Console::write_line(" Function: operator += (const Vec2<Type>& vector)"); { Vec2d testd(2.5, 3.5); testd += Vec2d(1.0, 2.0); if (testd.x != 3.5) fail(); if (testd.y != 5.5) fail(); Vec2i testi(2, 3); testi += Vec2i(1, 2); if (testi.x != 3) fail(); if (testi.y != 5) fail(); } Console::write_line(" Function: operator += ( Type value)"); { Vec2d testd(2.5, 3.5); double valued = 2.0; testd += valued; if (testd.x != 4.5) fail(); if (testd.y != 5.5) fail(); Vec2i testi(2, 3); int valuei = 2; testi += valuei; if (testi.x != 4) fail(); if (testi.y != 5) fail(); } Console::write_line(" Function: operator + (Type value)"); { Vec2d testd(2.5, 3.5); double valued = 2.0; testd = testd + valued; if (testd.x != 4.5) fail(); if (testd.y != 5.5) fail(); Vec2i testi(2, 3); int valuei = 2; testi = testi + valuei; if (testi.x != 4) fail(); if (testi.y != 5) fail(); } Console::write_line(" Function: operator + (const Vec2<Type>& vector)"); { Vec2d testd(2.5, 3.5); testd = testd + Vec2d(1.5, 2.5); if (testd.x != 4.0) fail(); if (testd.y != 6.0) fail(); Vec2i testi(2, 3); testi = testi + Vec2i(1, 2); if (testi.x != 3) fail(); if (testi.y != 5) fail(); } Console::write_line(" Function: operator -= (const Vec2<Type>& vector)"); { Vec2d testd(2.5, 3.5); testd -= Vec2d(1.0, 2.0); if (testd.x != 1.5) fail(); if (testd.y != 1.5) fail(); Vec2i testi(2, 3); testi -= Vec2i(1, 2); if (testi.x != 1) fail(); if (testi.y != 1) fail(); } Console::write_line(" Function: operator -= ( Type value)"); { Vec2d testd(2.5, 3.5); double valued = 2.0; testd -= valued; if (testd.x != 0.5) fail(); if (testd.y != 1.5) fail(); Vec2i testi(2, 3); int valuei = 2; testi -= valuei; if (testi.x != 0) fail(); if (testi.y != 1) fail(); } Console::write_line(" Function: operator - (Type value)"); { Vec2d testd(2.5, 3.5); double valued = 2.0; testd = testd - valued; if (testd.x != 0.5) fail(); if (testd.y != 1.5) fail(); Vec2i testi(2, 3); int valuei = 2; testi = testi - valuei; if (testi.x != 0) fail(); if (testi.y != 1) fail(); } Console::write_line(" Function: operator - (const Vec2<Type>& vector)"); { Vec2d testd(2.5, 3.5); testd = testd - Vec2d(1.5, 2.5); if (testd.x != 1.0) fail(); if (testd.y != 1.0) fail(); Vec2i testi(2, 3); testi = testi - Vec2i(1, 2); if (testi.x != 1) fail(); if (testi.y != 1) fail(); } Console::write_line(" Function: operator *= (const Vec2<Type>& vector)"); { Vec2d testd(2.5, 3.5); testd *= Vec2d(1.0, 2.0); if (testd.x != 2.5) fail(); if (testd.y != 7.0) fail(); Vec2i testi(2, 3); testi *= Vec2i(1, 2); if (testi.x != 2) fail(); if (testi.y != 6) fail(); } Console::write_line(" Function: operator *= ( Type value)"); { Vec2d testd(2.5, 3.5); double valued = 2.0; testd *= valued; if (testd.x != 5.0) fail(); if (testd.y != 7.0) fail(); Vec2i testi(2, 3); int valuei = 2; testi *= valuei; if (testi.x != 4) fail(); if (testi.y != 6) fail(); } Console::write_line(" Function: operator * (Type value)"); { Vec2d testd(2.5, 3.5); double valued = 2.0; testd = testd * valued; if (testd.x != 5.0) fail(); if (testd.y != 7.0) fail(); Vec2i testi(2, 3); int valuei = 2; testi = testi * valuei; if (testi.x != 4) fail(); if (testi.y != 6) fail(); } Console::write_line(" Function: operator * (const Vec2<Type>& vector)"); { Vec2d testd(2.5, 3.5); testd = testd * Vec2d(1.5, 2.5); if (testd.x != 3.75) fail(); if (testd.y != 8.75) fail(); Vec2i testi(2, 3); testi = testi * Vec2i(1, 2); if (testi.x != 2) fail(); if (testi.y != 6) fail(); } Console::write_line(" Function: operator /= (const Vec2<Type>& vector)"); { Vec2d testd(2.5, 3.5); testd /= Vec2d(1.0, 2.0); if (testd.x != 2.5) fail(); if (testd.y != 1.75) fail(); Vec2i testi(2, 10); testi /= Vec2i(1, 2); if (testi.x != 2) fail(); if (testi.y != 5) fail(); } Console::write_line(" Function: operator /= ( Type value)"); { Vec2d testd(2.5, 3.5); double valued = 2.0; testd /= valued; if (testd.x != 1.25) fail(); if (testd.y != 1.75) fail(); Vec2i testi(2, 10); int valuei = 2; testi /= valuei; if (testi.x != 1) fail(); if (testi.y != 5) fail(); } Console::write_line(" Function: operator / (Type value)"); { Vec2d testd(2.5, 3.5); double valued = 2.0; testd = testd / valued; if (testd.x != 1.25) fail(); if (testd.y != 1.75) fail(); Vec2i testi(2, 10); int valuei = 2; testi = testi / valuei; if (testi.x != 1) fail(); if (testi.y != 5) fail(); } Console::write_line(" Function: operator / (const Vec2<Type>& vector)"); { Vec2d testd(2.5, 3.5); testd = testd / Vec2d(1.0, 2.5); if (testd.x != 2.5) fail(); if (testd.y != 1.4) fail(); Vec2i testi(2, 10); testi = testi / Vec2i(1, 2); if (testi.x != 2) fail(); if (testi.y != 5) fail(); } Console::write_line(" Function: operator = (const Vec2<Type>& vector)"); { Vec2d testd(2.5, 3.5); testd = Vec2d(1.0, 2.0); if (testd.x != 1.0) fail(); if (testd.y != 2.0) fail(); Vec2i testi(2, 3); testi = Vec2i(1, 2); if (testi.x != 1) fail(); if (testi.y != 2) fail(); } Console::write_line(" Function: operator == (const Vec2<Type>& vector)"); { Vec2d testd(2.5, 3.5); if (testd == Vec2d(1.0, 2.0)) fail(); if (testd == Vec2d(2.5, 2.0)) fail(); if (!(testd == Vec2d(2.5, 3.5))) fail(); Vec2i testi(2, 3); if (testi == Vec2i(1, 2)) fail(); if (testi == Vec2i(2, 2)) fail(); if (!(testi == Vec2i(2, 3))) fail(); } Console::write_line(" Function: operator != (const Vec2<Type>& vector)"); { Vec2d testd(2.5, 3.5); if (!(testd != Vec2d(1.0, 2.0))) fail(); if (!(testd != Vec2d(2.5, 2.0))) fail(); if ((testd != Vec2d(2.5, 3.5))) fail(); Vec2i testi(2, 3); if (!(testi != Vec2i(1, 2))) fail(); if (!(testi != Vec2i(2, 2))) fail(); if ((testi != Vec2i(2, 3))) fail(); } Console::write_line(" Function: round()"); { Vec2d testd(2.0, 2.5); testd.round(); if (testd.x != 2.0) fail(); if (testd.y != 3.0) fail(); Vec2f testf(2.0f, 2.5f); testf.round(); if (testf.x != 2.0f) fail(); if (testf.y != 3.0f) fail(); } Console::write_line(" Function: static round()"); { Vec2d testd(2.0, 2.5); Vec2d destd = Vec2d::round(testd); if (destd.x != 2.0) fail(); if (destd.y != 3.0) fail(); Vec2f testf(2.0f, 2.5f); Vec2f destf = Vec2f::round(testf); if (destf.x != 2.0f) fail(); if (destf.y != 3.0f) fail(); } }
void TestApp::test_vector3(void) { Console::write_line(" Header: cl_vector.h"); Console::write_line(" Class: Vec3"); Console::write_line(" Function: distance()"); { Vec3d test_a(2.0,3.0,4.0); Vec3d test_b(3.0,4.0,5.0); if (test_a.distance(test_b) != sqrt(1.0 + 1.0 + 1.0 )) fail(); } Console::write_line(" Function: normalize()"); { Vec3d testi(3.0,4.0,5.0); testi.normalize(); if (testi != Vec3d(3.0/sqrt(50.0), 4.0/sqrt(50.0), 5.0/sqrt(50.0))) fail(); } Console::write_line(" Function: static normalize()"); { Vec3d testi(3.0,4.0,5.0); if (Vec3d::normalize(testi) != Vec3d(3.0/sqrt(50.0), 4.0/sqrt(50.0), 5.0/sqrt(50.0))) fail(); } Console::write_line(" Function: length()"); { Vec3d testi(3.0,4.0,5.0); if (testi.length() != sqrt(50.0 )) fail(); } Console::write_line(" Function: dot()"); { Vec3d test_a(3.0,4.0,5.0); Vec3d test_b(13.0,14.0,15.0); if (test_a.dot(test_b) != ((3.0 * 13.0)+ (4.0*14.0) + (5.0 * 15.0))) fail(); } Console::write_line(" Function: operator += (const Vec3<Type>& vector)"); { Vec3d testd(2.5, 3.5, 4.5); testd += Vec3d(1.0, 2.0, 3.0); if (testd.x != 3.5) fail(); if (testd.y != 5.5) fail(); if (testd.z != 7.5) fail(); Vec3i testi(2, 3, 4); testi += Vec3i(1, 2, 3); if (testi.x != 3) fail(); if (testi.y != 5) fail(); if (testi.z != 7) fail(); } Console::write_line(" Function: operator += ( Type value)"); { Vec3d testd(2.5, 3.5, 4.5); double valued = 2.0; testd += valued; if (testd.x != 4.5) fail(); if (testd.y != 5.5) fail(); if (testd.z != 6.5) fail(); Vec3i testi(2, 3, 4); int valuei = 2; testi += valuei; if (testi.x != 4) fail(); if (testi.y != 5) fail(); if (testi.z != 6) fail(); } Console::write_line(" Function: operator + (Type value)"); { Vec3d testd(2.5, 3.5, 4.5); double valued = 2.0; testd = testd + valued; if (testd.x != 4.5) fail(); if (testd.y != 5.5) fail(); if (testd.z != 6.5) fail(); Vec3i testi(2, 3, 4); int valuei = 2; testi = testi + valuei; if (testi.x != 4) fail(); if (testi.y != 5) fail(); if (testi.z != 6) fail(); } Console::write_line(" Function: operator + (const Vec3<Type>& vector)"); { Vec3d testd(2.5, 3.5, 4.5); testd = testd + Vec3d(1.5, 2.5, 3.5); if (testd.x != 4.0) fail(); if (testd.y != 6.0) fail(); if (testd.z != 8.0) fail(); Vec3i testi(2, 3, 4); testi = testi + Vec3i(1, 2, 3); if (testi.x != 3) fail(); if (testi.y != 5) fail(); if (testi.z != 7) fail(); } Console::write_line(" Function: operator -= (const Vec3<Type>& vector)"); { Vec3d testd(2.5, 3.5, 4.5); testd -= Vec3d(1.0, 2.0, 3.0); if (testd.x != 1.5) fail(); if (testd.y != 1.5) fail(); if (testd.z != 1.5) fail(); Vec3i testi(2, 3, 4); testi -= Vec3i(1, 2, 3); if (testi.x != 1) fail(); if (testi.y != 1) fail(); if (testi.z != 1) fail(); } Console::write_line(" Function: operator -= ( Type value)"); { Vec3d testd(2.5, 3.5, 4.5); double valued = 2.0; testd -= valued; if (testd.x != 0.5) fail(); if (testd.y != 1.5) fail(); if (testd.z != 2.5) fail(); Vec3i testi(2, 3, 4); int valuei = 2; testi -= valuei; if (testi.x != 0) fail(); if (testi.y != 1) fail(); if (testi.z != 2) fail(); } Console::write_line(" Function: operator - (Type value)"); { Vec3d testd(2.5, 3.5, 4.5); double valued = 2.0; testd = testd - valued; if (testd.x != 0.5) fail(); if (testd.y != 1.5) fail(); if (testd.z != 2.5) fail(); Vec3i testi(2, 3, 4); int valuei = 2; testi = testi - valuei; if (testi.x != 0) fail(); if (testi.y != 1) fail(); if (testi.z != 2) fail(); } Console::write_line(" Function: operator - (const Vec3<Type>& vector)"); { Vec3d testd(2.5, 3.5, 4.5); testd = testd - Vec3d(1.5, 2.5, 3.5); if (testd.x != 1.0) fail(); if (testd.y != 1.0) fail(); if (testd.z != 1.0) fail(); Vec3i testi(2, 3, 4); testi = testi - Vec3i(1, 2, 3); if (testi.x != 1) fail(); if (testi.y != 1) fail(); if (testi.z != 1) fail(); } Console::write_line(" Function: operator *= (const Vec3<Type>& vector)"); { Vec3d testd(2.5, 3.5, 4.5); testd *= Vec3d(1.0, 2.0, 3.0); if (testd.x != 2.5) fail(); if (testd.y != 7.0) fail(); if (testd.z != 13.5) fail(); Vec3i testi(2, 3, 4); testi *= Vec3i(1, 2, 3); if (testi.x != 2) fail(); if (testi.y != 6) fail(); if (testi.z != 12) fail(); } Console::write_line(" Function: operator *= ( Type value)"); { Vec3d testd(2.5, 3.5, 4.5); double valued = 2.0; testd *= valued; if (testd.x != 5.0) fail(); if (testd.y != 7.0) fail(); if (testd.z != 9.0) fail(); Vec3i testi(2, 3, 4); int valuei = 2; testi *= valuei; if (testi.x != 4) fail(); if (testi.y != 6) fail(); if (testi.z != 8) fail(); } Console::write_line(" Function: operator * (Type value)"); { Vec3d testd(2.5, 3.5, 4.5); double valued = 2.0; testd = testd * valued; if (testd.x != 5.0) fail(); if (testd.y != 7.0) fail(); if (testd.z != 9.0) fail(); Vec3i testi(2, 3, 4); int valuei = 2; testi = testi * valuei; if (testi.x != 4) fail(); if (testi.y != 6) fail(); if (testi.z != 8) fail(); } Console::write_line(" Function: operator * (const Vec3<Type>& vector)"); { Vec3d testd(2.5, 3.5, 4.5); testd = testd * Vec3d(1.5, 2.5, 3.5); if (testd.x != 3.75) fail(); if (testd.y != 8.75) fail(); if (testd.z != 15.75) fail(); Vec3i testi(2, 3, 4); testi = testi * Vec3i(1, 2, 3); if (testi.x != 2) fail(); if (testi.y != 6) fail(); if (testi.z != 12) fail(); } Console::write_line(" Function: operator /= (const Vec3<Type>& vector)"); { Vec3d testd(2.5, 3.5, 4.5); testd /= Vec3d(1.0, 2.0, 3.0); if (testd.x != 2.5) fail(); if (testd.y != 1.75) fail(); if (testd.z != 1.5) fail(); Vec3i testi(2, 10, 20); testi /= Vec3i(1, 2, 3); if (testi.x != 2) fail(); if (testi.y != 5) fail(); if (testi.z != 6) fail(); } Console::write_line(" Function: operator /= ( Type value)"); { Vec3d testd(2.5, 3.5, 4.5); double valued = 2.0; testd /= valued; if (testd.x != 1.25) fail(); if (testd.y != 1.75) fail(); if (testd.z != 2.25) fail(); Vec3i testi(2, 10, 20); int valuei = 2; testi /= valuei; if (testi.x != 1) fail(); if (testi.y != 5) fail(); if (testi.z != 10) fail(); } Console::write_line(" Function: operator / (Type value)"); { Vec3d testd(2.5, 3.5, 4.5); double valued = 2.0; testd = testd / valued; if (testd.x != 1.25) fail(); if (testd.y != 1.75) fail(); if (testd.z != 2.25) fail(); Vec3i testi(2, 10, 20); int valuei = 2; testi = testi / valuei; if (testi.x != 1) fail(); if (testi.y != 5) fail(); if (testi.z != 10) fail(); } Console::write_line(" Function: operator / (const Vec3<Type>& vector)"); { Vec3d testd(2.5, 3.5, 4.5); testd = testd / Vec3d(1.0, 2.5, 4.5); if (testd.x != 2.5) fail(); if (testd.y != 1.4) fail(); if (testd.z != 1.0) fail(); Vec3i testi(2, 10, 20); testi = testi / Vec3i(1, 2, 3); if (testi.x != 2) fail(); if (testi.y != 5) fail(); if (testi.z != 6) fail(); } Console::write_line(" Function: operator = (const Vec3<Type>& vector)"); { Vec3d testd(2.5, 3.5, 4.5); testd = Vec3d(1.0, 2.0, 3.0); if (testd.x != 1.0) fail(); if (testd.y != 2.0) fail(); if (testd.z != 3.0) fail(); Vec3i testi(2, 3, 4); testi = Vec3i(1, 2, 3); if (testi.x != 1) fail(); if (testi.y != 2) fail(); if (testi.z != 3) fail(); } Console::write_line(" Function: operator == (const Vec3<Type>& vector)"); { Vec3d testd(2.5, 3.5, 4.5); if (testd == Vec3d(1.0, 2.0, 3.0)) fail(); if (testd == Vec3d(2.5, 2.0, 3.0)) fail(); if (testd == Vec3d(2.5, 3.5, 3.0)) fail(); if (!(testd == Vec3d(2.5, 3.5, 4.5))) fail(); Vec3i testi(2, 3, 4); if (testi == Vec3i(1, 2, 3)) fail(); if (testi == Vec3i(2, 2, 3)) fail(); if (testi == Vec3i(2, 3, 3)) fail(); if (!(testi == Vec3i(2, 3, 4))) fail(); } Console::write_line(" Function: operator != (const Vec3<Type>& vector)"); { Vec3d testd(2.5, 3.5, 4.5); if (!(testd != Vec3d(1.0, 2.0, 3.0))) fail(); if (!(testd != Vec3d(2.5, 2.0, 3.0))) fail(); if (!(testd != Vec3d(2.5, 3.5, 3.0))) fail(); if ((testd != Vec3d(2.5, 3.5, 4.5))) fail(); Vec3i testi(2, 3, 4); if (!(testi != Vec3i(1, 2, 3))) fail(); if (!(testi != Vec3i(2, 2, 3))) fail(); if (!(testi != Vec3i(2, 3, 3))) fail(); if ((testi != Vec3i(2, 3, 4))) fail(); } Console::write_line(" Function: round()"); { Vec3d testd(2.0, 2.5, -2.0); testd.round(); if (testd.x != 2.0) fail(); if (testd.y != 3.0) fail(); if (testd.z != -2.0) fail(); Vec3f testf(2.0f, 2.5f, -2.0f); testf.round(); if (testf.x != 2.0f) fail(); if (testf.y != 3.0f) fail(); if (testf.z != -2.0f) fail(); } Console::write_line(" Function: static round()"); { Vec3d testd(2.0, 2.5, -2.0); Vec3d destd = Vec3d::round(testd); if (destd.x != 2.0) fail(); if (destd.y != 3.0) fail(); if (destd.z != -2.0) fail(); Vec3f testf(2.0f, 2.5f, -2.0f); Vec3f destf = Vec3f::round(testf); if (destf.x != 2.0f) fail(); if (destf.y != 3.0f) fail(); if (destf.z != -2.0f) fail(); } Console::write_line(" Function: Vec3<Type> operator * (const Mat3<Type>& matrix, const Vec3<Type>& v)"); { /// Matrix is assumed to be in the Column-Major matrix format (opengl native)\n Mat3f matrix(1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f); Vec3f vector(1.0f, 2.0f, 3.0f); Vec3f result = matrix * vector; if (result.x != ( (matrix[0 + 3*0] * vector.x) + (matrix[0 + 3*1] * vector.y) + (matrix[0 + 3*2] * vector.z) ) ) fail(); if (result.y != ( (matrix[1 + 3*0] * vector.x) + (matrix[1 + 3*1] * vector.y) + (matrix[1 + 3*2] * vector.z) ) ) fail(); if (result.z != ( (matrix[2 + 3*0] * vector.x) + (matrix[2 + 3*1] * vector.y) + (matrix[2 + 3*2] * vector.z) ) ) fail(); } }
void TestApp::test_vector4(void) { Console::write_line(" Header: cl_vector.h"); Console::write_line(" Class: Vec4"); Console::write_line(" Function: distance3()"); { Vec4d test_a(2.0,3.0,4.0,5.0); Vec4d test_b(3.0,4.0,5.0,6.0); if (test_a.distance3(test_b) != sqrt(1.0 + 1.0 + 1.0 )) fail(); } Console::write_line(" Function: distance4()"); { Vec4d test_a(2.0,3.0,4.0,5.0); Vec4d test_b(3.0,4.0,5.0,6.0); if (test_a.distance4(test_b) != sqrt(1.0 + 1.0 + 1.0 + 1.0 )) fail(); } Console::write_line(" Function: length3()"); { Vec4d testi(3.0,4.0,5.0,6.0); if (testi.length3() != sqrt(50.0 )) fail(); } Console::write_line(" Function: length4()"); { Vec4d testi(3.0,4.0,5.0,6.0); if (testi.length4() != sqrt(86.0 )) fail(); } Console::write_line(" Function: normalize3()"); { Vec4d testi(3.0,4.0,5.0,6.0); testi.normalize3(); if (testi != Vec4d(3.0/sqrt(50.0), 4.0/sqrt(50.0), 5.0/sqrt(50.0), 6.0)) fail(); } Console::write_line(" Function: static normalize3()"); { Vec4d testi(3.0,4.0,5.0,6.0); if (Vec4d::normalize3(testi) != Vec4d(3.0/sqrt(50.0), 4.0/sqrt(50.0), 5.0/sqrt(50.0), 6.0)) fail(); } Console::write_line(" Function: dot3()"); { Vec4d test_a(3.0,4.0,5.0,6.0); Vec4d test_b(13.0,14.0,15.0,16.0); if (test_a.dot3(test_b) != ((3.0 * 13.0)+ (4.0*14.0) + (5.0 * 15.0))) fail(); } Console::write_line(" Function: dot4()"); { Vec4d test_a(3.0,4.0,5.0,6.0); Vec4d test_b(13.0,14.0,15.0,16.0); if (test_a.dot4(test_b) != ((3.0 * 13.0)+ (4.0*14.0) + (5.0 * 15.0) + (6.0 * 16.0))) fail(); } Console::write_line(" Function: normalize4()"); { Vec4d testi(3.0,4.0,5.0,6.0); testi.normalize4(); if (testi != Vec4d(3.0/sqrt(86.0), 4.0/sqrt(86.0), 5.0/sqrt(86.0), 6.0/sqrt(86.0))) fail(); } Console::write_line(" Function: static normalize4()"); { Vec4d testi(3.0,4.0,5.0,6.0); if (Vec4d::normalize4(testi) != Vec4d(3.0/sqrt(86.0), 4.0/sqrt(86.0), 5.0/sqrt(86.0), 6.0/sqrt(86.0))) fail(); } Console::write_line(" Function: operator += (const Vec4<Type>& vector)"); { Vec4d testd(2.5, 3.5, 4.5, 5.5); testd += Vec4d(1.0, 2.0, 3.0, 4.0); if (testd.x != 3.5) fail(); if (testd.y != 5.5) fail(); if (testd.z != 7.5) fail(); if (testd.w != 9.5) fail(); Vec4i testi(2, 3, 4, 5); testi += Vec4i(1, 2, 3, 4); if (testi.x != 3) fail(); if (testi.y != 5) fail(); if (testi.z != 7) fail(); if (testi.w != 9) fail(); } Console::write_line(" Function: operator += ( Type value)"); { Vec4d testd(2.5, 3.5, 4.5, 5.5); double valued = 2.0; testd += valued; if (testd.x != 4.5) fail(); if (testd.y != 5.5) fail(); if (testd.z != 6.5) fail(); if (testd.w != 7.5) fail(); Vec4i testi(2, 3, 4, 5); int valuei = 2; testi += valuei; if (testi.x != 4) fail(); if (testi.y != 5) fail(); if (testi.z != 6) fail(); if (testi.w != 7) fail(); } Console::write_line(" Function: operator + (Type value)"); { Vec4d testd(2.5, 3.5, 4.5, 5.5); double valued = 2.0; testd = testd + valued; if (testd.x != 4.5) fail(); if (testd.y != 5.5) fail(); if (testd.z != 6.5) fail(); if (testd.w != 7.5) fail(); Vec4i testi(2, 3, 4, 5); int valuei = 2; testi = testi + valuei; if (testi.x != 4) fail(); if (testi.y != 5) fail(); if (testi.z != 6) fail(); if (testi.w != 7) fail(); } Console::write_line(" Function: operator + (const Vec4<Type>& vector)"); { Vec4d testd(2.5, 3.5, 4.5, 5.5); testd = testd + Vec4d(1.5, 2.5, 3.5, 4.5); if (testd.x != 4.0) fail(); if (testd.y != 6.0) fail(); if (testd.z != 8.0) fail(); if (testd.w != 10.0) fail(); Vec4i testi(2, 3, 4, 5); testi = testi + Vec4i(1, 2, 3, 4); if (testi.x != 3) fail(); if (testi.y != 5) fail(); if (testi.z != 7) fail(); if (testi.w != 9) fail(); } Console::write_line(" Function: operator -= (const Vec4<Type>& vector)"); { Vec4d testd(2.5, 3.5, 4.5, 5.5); testd -= Vec4d(1.0, 2.0, 3.0, 4.0); if (testd.x != 1.5) fail(); if (testd.y != 1.5) fail(); if (testd.z != 1.5) fail(); if (testd.w != 1.5) fail(); Vec4i testi(2, 3, 4, 5); testi -= Vec4i(1, 2, 3, 4); if (testi.x != 1) fail(); if (testi.y != 1) fail(); if (testi.z != 1) fail(); if (testi.w != 1) fail(); } Console::write_line(" Function: operator -= ( Type value)"); { Vec4d testd(2.5, 3.5, 4.5, 5.5); double valued = 2.0; testd -= valued; if (testd.x != 0.5) fail(); if (testd.y != 1.5) fail(); if (testd.z != 2.5) fail(); if (testd.w != 3.5) fail(); Vec4i testi(2, 3, 4, 5); int valuei = 2; testi -= valuei; if (testi.x != 0) fail(); if (testi.y != 1) fail(); if (testi.z != 2) fail(); if (testi.w != 3) fail(); } Console::write_line(" Function: operator - (Type value)"); { Vec4d testd(2.5, 3.5, 4.5, 5.5); double valued = 2.0; testd = testd - valued; if (testd.x != 0.5) fail(); if (testd.y != 1.5) fail(); if (testd.z != 2.5) fail(); if (testd.w != 3.5) fail(); Vec4i testi(2, 3, 4, 5); int valuei = 2; testi = testi - valuei; if (testi.x != 0) fail(); if (testi.y != 1) fail(); if (testi.z != 2) fail(); if (testi.w != 3) fail(); } Console::write_line(" Function: operator - (const Vec4<Type>& vector)"); { Vec4d testd(2.5, 3.5, 4.5, 5.5); testd = testd - Vec4d(1.5, 2.5, 3.5, 4.5); if (testd.x != 1.0) fail(); if (testd.y != 1.0) fail(); if (testd.z != 1.0) fail(); if (testd.w != 1.0) fail(); Vec4i testi(2, 3, 4, 5); testi = testi - Vec4i(1, 2, 3, 4); if (testi.x != 1) fail(); if (testi.y != 1) fail(); if (testi.z != 1) fail(); if (testi.w != 1) fail(); } Console::write_line(" Function: operator *= (const Vec4<Type>& vector)"); { Vec4d testd(2.5, 3.5, 4.5, 5.5); testd *= Vec4d(1.0, 2.0, 3.0, 4.0); if (testd.x != 2.5) fail(); if (testd.y != 7.0) fail(); if (testd.z != 13.5) fail(); if (testd.w != 22.0) fail(); Vec4i testi(2, 3, 4, 5); testi *= Vec4i(1, 2, 3, 4); if (testi.x != 2) fail(); if (testi.y != 6) fail(); if (testi.z != 12) fail(); if (testi.w != 20) fail(); } Console::write_line(" Function: operator *= ( Type value)"); { Vec4d testd(2.5, 3.5, 4.5, 5.5); double valued = 2.0; testd *= valued; if (testd.x != 5.0) fail(); if (testd.y != 7.0) fail(); if (testd.z != 9.0) fail(); if (testd.w != 11.0) fail(); Vec4i testi(2, 3, 4, 5); int valuei = 2; testi *= valuei; if (testi.x != 4) fail(); if (testi.y != 6) fail(); if (testi.z != 8) fail(); if (testi.w != 10) fail(); } Console::write_line(" Function: operator * (Type value)"); { Vec4d testd(2.5, 3.5, 4.5, 5.5); double valued = 2.0; testd = testd * valued; if (testd.x != 5.0) fail(); if (testd.y != 7.0) fail(); if (testd.z != 9.0) fail(); if (testd.w != 11.0) fail(); Vec4i testi(2, 3, 4, 5); int valuei = 2; testi = testi * valuei; if (testi.x != 4) fail(); if (testi.y != 6) fail(); if (testi.z != 8) fail(); if (testi.w != 10) fail(); } Console::write_line(" Function: operator * (const Vec4<Type>& vector)"); { Vec4d testd(2.5, 3.5, 4.5, 5.5); testd = testd * Vec4d(1.5, 2.5, 3.5, 4.5); if (testd.x != 3.75) fail(); if (testd.y != 8.75) fail(); if (testd.z != 15.75) fail(); if (testd.w != 24.75) fail(); Vec4i testi(2, 3, 4, 5); testi = testi * Vec4i(1, 2, 3, 4); if (testi.x != 2) fail(); if (testi.y != 6) fail(); if (testi.z != 12) fail(); if (testi.w != 20) fail(); } Console::write_line(" Function: operator /= (const Vec4<Type>& vector)"); { Vec4d testd(2.5, 3.5, 4.5, 5.5); testd /= Vec4d(1.0, 2.0, 3.0, 4.0); if (testd.x != 2.5) fail(); if (testd.y != 1.75) fail(); if (testd.z != 1.5) fail(); if (testd.w != 1.375) fail(); Vec4i testi(2, 10, 20, 5); testi /= Vec4i(1, 2, 3, 4); if (testi.x != 2) fail(); if (testi.y != 5) fail(); if (testi.z != 6) fail(); if (testi.w != 1) fail(); } Console::write_line(" Function: operator /= ( Type value)"); { Vec4d testd(2.5, 3.5, 4.5, 5.5); double valued = 2.0; testd /= valued; if (testd.x != 1.25) fail(); if (testd.y != 1.75) fail(); if (testd.z != 2.25) fail(); if (testd.w != 2.75) fail(); Vec4i testi(2, 10, 20, 5); int valuei = 2; testi /= valuei; if (testi.x != 1) fail(); if (testi.y != 5) fail(); if (testi.z != 10) fail(); if (testi.w != 2) fail(); } Console::write_line(" Function: operator / (Type value)"); { Vec4d testd(2.5, 3.5, 4.5, 5.5); double valued = 2.0; testd = testd / valued; if (testd.x != 1.25) fail(); if (testd.y != 1.75) fail(); if (testd.z != 2.25) fail(); if (testd.w != 2.75) fail(); Vec4i testi(2, 10, 20, 5); int valuei = 2; testi = testi / valuei; if (testi.x != 1) fail(); if (testi.y != 5) fail(); if (testi.z != 10) fail(); if (testi.w != 2) fail(); } Console::write_line(" Function: operator / (const Vec4<Type>& vector)"); { Vec4d testd(2.5, 3.5, 4.5, 10.0); testd = testd / Vec4d(1.0, 2.5, 4.5, 2.0); if (testd.x != 2.5) fail(); if (testd.y != 1.4) fail(); if (testd.z != 1.0) fail(); if (testd.w != 5.0) fail(); Vec4i testi(2, 10, 20, 5); testi = testi / Vec4i(1, 2, 3, 4); if (testi.x != 2) fail(); if (testi.y != 5) fail(); if (testi.z != 6) fail(); if (testi.w != 1) fail(); } Console::write_line(" Function: operator = (const Vec4<Type>& vector)"); { Vec4d testd(2.5, 3.5, 4.5, 5.5); testd = Vec4d(1.0, 2.0, 3.0, 4.0); if (testd.x != 1.0) fail(); if (testd.y != 2.0) fail(); if (testd.z != 3.0) fail(); if (testd.w != 4.0) fail(); Vec4i testi(2, 3, 4, 5); testi = Vec4i(1, 2, 3, 4); if (testi.x != 1) fail(); if (testi.y != 2) fail(); if (testi.z != 3) fail(); if (testi.w != 4) fail(); } Console::write_line(" Function: operator == (const Vec4<Type>& vector)"); { Vec4d testd(2.5, 3.5, 4.5, 5.5); if (testd == Vec4d(1.0, 2.0, 3.0, 4.0)) fail(); if (testd == Vec4d(2.5, 2.0, 3.0, 4.0)) fail(); if (testd == Vec4d(2.5, 3.5, 3.0, 4.0)) fail(); if (testd == Vec4d(2.5, 3.5, 4.5, 4.0)) fail(); if (!(testd == Vec4d(2.5, 3.5, 4.5, 5.5))) fail(); Vec4i testi(2, 3, 4, 5); if (testi == Vec4i(1, 2, 3, 4)) fail(); if (testi == Vec4i(2, 2, 3, 4)) fail(); if (testi == Vec4i(2, 3, 3, 4)) fail(); if (testi == Vec4i(2, 3, 4, 4)) fail(); if (!(testi == Vec4i(2, 3, 4, 5))) fail(); } Console::write_line(" Function: operator != (const Vec4<Type>& vector)"); { Vec4d testd(2.5, 3.5, 4.5, 5.5); if (!(testd != Vec4d(1.0, 2.0, 3.0, 4.0))) fail(); if (!(testd != Vec4d(2.5, 2.0, 3.0, 4.0))) fail(); if (!(testd != Vec4d(2.5, 3.5, 3.0, 4.0))) fail(); if (!(testd != Vec4d(2.5, 3.5, 4.5, 4.0))) fail(); if ((testd != Vec4d(2.5, 3.5, 4.5, 5.5))) fail(); Vec4i testi(2, 3, 4, 5); if (!(testi != Vec4i(1, 2, 3, 4))) fail(); if (!(testi != Vec4i(2, 2, 3, 4))) fail(); if (!(testi != Vec4i(2, 3, 3, 4))) fail(); if (!(testi != Vec4i(2, 3, 4, 4))) fail(); if ((testi != Vec4i(2, 3, 4, 5))) fail(); } Console::write_line(" Function: round()"); { Vec4d testd(2.0, 2.5, -2.0, -2.5); testd.round(); if (testd.x != 2.0) fail(); if (testd.y != 3.0) fail(); if (testd.z != -2.0) fail(); if (testd.w != -2.0) fail(); Vec4f testf(2.0f, 2.5f, -2.0f, -2.9f); testf.round(); if (testf.x != 2.0f) fail(); if (testf.y != 3.0f) fail(); if (testf.z != -2.0f) fail(); if (testf.w != -3.0f) fail(); } Console::write_line(" Function: static round()"); { Vec4d testd(2.0, 2.5, -2.0, -2.5); Vec4d destd = Vec4d::round(testd); if (destd.x != 2.0) fail(); if (destd.y != 3.0) fail(); if (destd.z != -2.0) fail(); if (destd.w != -2.0) fail(); Vec4f testf(2.0f, 2.5f, -2.0f, -2.9f); Vec4f destf = Vec4f::round(testf); if (destf.x != 2.0f) fail(); if (destf.y != 3.0f) fail(); if (destf.z != -2.0f) fail(); if (destf.w != -3.0f) fail(); } }