Crafter.Math/tests/VectorF16.cpp

52 lines
1.7 KiB
C++

/*
Crafter® Build
Copyright (C) 2026 Catcrafts®
Catcrafts.net
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License version 3.0 as published by the Free Software Foundation;
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import Crafter.Math;
import std;
using namespace Crafter;
extern "C" {
std::string* RunTest() {
{
_Float16 floats[] {0,1,2,3,4,5,6,7,8};
VectorF16<8, 1> vec1(floats);
Vector<_Float16, 8, VectorF16<8, 1>::Alignment> stored = vec1.Store();
for(std::uint8_t i = 0; i < 8; i++) {
if(stored.v[i] != floats[i]) {
return new std::string("Load Store does not match");
}
}
}
{
_Float16 floats[] {0,1,2,3,4,5,6,7,8};
VectorF16<8, 1> vec1(floats);
VectorF16<8, 1> result = vec1 + vec1;
Vector<_Float16, 8, VectorF16<8, 1>::Alignment> stored = result.Store();
for(std::uint8_t i = 0; i < 8; i++) {
if(stored.v[i] != floats[i] + floats[i]) {
return new std::string("Add does not match");
}
}
}
return nullptr;
}
}