Adding tests for trigamma

This commit is contained in:
heisenbuug
2021-11-11 02:17:42 +05:30
parent 13929f5a2d
commit 6fe4ad2f45
+34
View File
@@ -0,0 +1,34 @@
/**
* @file tests/digamma_test.cpp
* @author Gopi Tatiraju
*
* Test the trigamma function.
*
* mlpack is free software; you may redistribute it and/or modify it under the
* terms of the 3-clause BSD license. You should have received a copy of the
* 3-clause BSD license along with mlpack. If not, see
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
*/
#include <mlpack/core.hpp>
#include <mlpack/core/math/trigamma.hpp>
#include "catch.hpp"
#include "test_catch_tools.hpp"
using namespace mlpack;
using namespace math;
/**
* Test the output of trigamma for input values.
*/
TEST_CASE("Trigamma", "[TrigammaTest]")
{
arma::mat data;
if (!data::Load("trigamma_data.csv", data, true, false))
FAIL("Cannot load data trigamma_data.csv");
for (size_t i = 0; i < data.n_rows; i++)
REQUIRE(Trigamma(data(i, 0)) == Approx(data(i, 1)).epsilon(1e-7));
}