Developer documentation
Version 3.0.3-105-gd3941f44
betainc.h
Go to the documentation of this file.
1/* Copyright (c) 2008-2022 the MRtrix3 contributors.
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 *
7 * Covered Software is provided under this License on an "as is"
8 * basis, without warranty of any kind, either expressed, implied, or
9 * statutory, including, without limitation, warranties that the
10 * Covered Software is free of defects, merchantable, fit for a
11 * particular purpose or non-infringing.
12 * See the Mozilla Public License v. 2.0 for more details.
13 *
14 * For more details, see http://www.mrtrix.org/.
15 */
16
17#ifndef __math_betainc_h__
18#define __math_betainc_h__
19
20#ifdef MRTRIX_HAVE_EIGEN_UNSUPPORTED_SPECIAL_FUNCTIONS
21#include <unsupported/Eigen/SpecialFunctions>
22#endif
23
24#include <math.h>
25#include "types.h"
26
27
28namespace MR
29{
30 namespace Math
31 {
32
33
34
35#ifdef MRTRIX_HAVE_EIGEN_UNSUPPORTED_SPECIAL_FUNCTIONS
36
37 // Compute the *regularised* incomplete beta function using
38 // the incomplete beta function as provided in Eigen 3.3 and above
39 template <typename ArgADerived, typename ArgBDerived, typename ArgXDerived>
40 inline const Eigen::Array<typename ArgXDerived::Scalar, Eigen::Dynamic, Eigen::Dynamic>
41 betaincreg (const Eigen::ArrayBase<ArgADerived>& a, const Eigen::ArrayBase<ArgBDerived>& b, const Eigen::ArrayBase<ArgXDerived>& x)
42 {
43 Eigen::Array<typename ArgXDerived::Scalar, Eigen::Dynamic, Eigen::Dynamic> ones (x);
44 ones.fill (typename ArgXDerived::Scalar (1));
45 return (Eigen::betainc (a, b, x) / Eigen::betainc (a, b, ones)).eval();
46 };
47
48#endif
49
50
51
52
54
55
56
57 }
58}
59
60#endif
default_type betaincreg(const default_type a, const default_type b, const default_type x)
Definition: base.h:24
double default_type
the default type used throughout MRtrix
Definition: types.h:228