From 6fe4ad2f45ffcbd595e822cdc0e2fe7ff7a466b3 Mon Sep 17 00:00:00 2001 From: heisenbuug Date: Thu, 11 Nov 2021 02:17:42 +0530 Subject: [PATCH] Adding tests for trigamma --- src/mlpack/tests/trigamma_test.cpp | 34 ++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/mlpack/tests/trigamma_test.cpp diff --git a/src/mlpack/tests/trigamma_test.cpp b/src/mlpack/tests/trigamma_test.cpp new file mode 100644 index 0000000000..7cc5aea166 --- /dev/null +++ b/src/mlpack/tests/trigamma_test.cpp @@ -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 +#include + +#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)); +} +