Page MenuHomec4science

test_static_types.cpp
No OneTemporary

File Metadata

Created
Wed, Jun 26, 12:03

test_static_types.cpp

/**
*
* @author Lucas Frérot <lucas.frerot@epfl.ch>
*
* @section LICENSE
*
* Copyright (©) 2017 EPFL (Ecole Polytechnique Fédérale de
* Lausanne) Laboratory (LSMS - Laboratoire de Simulation en Mécanique des
* Solides)
*
* Tamaas is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Tamaas 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 Tamaas. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "test.hh"
#include "static_types.hh"
using namespace tamaas;
/* -------------------------------------------------------------------------- */
TEST(TestStaticTypes, GEMV) {
UInt A_[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
UInt b_[] = {1, 2, 3};
MatrixProxy<UInt, 3, 3> A(A_[0]);
VectorProxy<UInt, 3> b(b_[0]);
auto res = A * b;
std::vector<UInt> solution = {14, 32, 50};
ASSERT_TRUE(compare(res, solution)) << "Matrix multiplication fail";
}
TEST(TestStaticTypes, Dot) {
UInt a_[] = {2, 3};
UInt b_[] = {1, 5};
VectorProxy<UInt, 2> a(a_[0]), b(b_[0]);
ASSERT_EQ(a.dot(b), 17) << "Dot product fail";
}
TEST(TestStaticTypes, Norm) {
Real a_[] = {3., 4.};
VectorProxy<Real, 2> a(a_[0]);
ASSERT_DOUBLE_EQ(a.l2norm(), 5) << "L2 norm fail";
}

Event Timeline