This file is indexed.

/usr/include/shogun/mathematics/JacobiEllipticFunctions.h is in libshogun-dev 3.2.0-7.5.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * Written (W) 2013 Soumyajit De
 *
 * KRYLSTAT Copyright 2011 by Erlend Aune <erlenda@math.ntnu.no> under GPL2+
 * (few parts rewritten and adjusted for shogun)
 *
 * NOTE: For higher precision, the methods in this class rely on an external
 * library, ARPREC (http://crd-legacy.lbl.gov/~dhbailey/mpdist/), in absense of
 * which they fallback to shogun datatypes. To use it with shogun, configure
 * ARPREC with `CXX="c++ -fPIC" ./configure' in order to link.
 */

#ifndef JACOBI_ELLIPTIC_FUNCTIONS_H_
#define JACOBI_ELLIPTIC_FUNCTIONS_H_

#include <shogun/lib/config.h>
#include <shogun/base/SGObject.h>
#include <limits>
#include <math.h>

#ifdef HAVE_ARPREC
#include <arprec/mp_real.h>
#include <arprec/mp_complex.h>
#endif //HAVE_ARPREC

namespace shogun
{

/** @brief Class that contains methods for computing Jacobi elliptic functions
 * related to complex analysis. These functions are inverse of the elliptic
 * integral of first kind, i.e.
 * \f[
 * u(k,m)=\int_{0}^{k}\frac{dt}{\sqrt{(1-t^{2})(1-m^{2}t^{2})}}
 * =\int_{0}^{\varphi}\frac{d\theta}{\sqrt{(1-m^{2}sin^{2}\theta)}}
 * \f]
 * where \f$k=sin\varphi\f$, \f$t=sin\theta\f$ and parameter \f$m, 0\le m
 * \le 1\f$ is called modulus. Three main Jacobi elliptic functions are defined
 * as \f$sn(u,m)=k=sin\theta\f$, \f$cn(u,m)=cos\theta=\sqrt{1-sn(u,m)^{2}}\f$
 * and \f$dn(u,m)=\sqrt{1-m^{2}sn(u,m)^{2}}\f$.
 * For \f$k=1\f$, i.e. \f$\varphi=\frac{\pi}{2}\f$, \f$u(1,m)=K(m)\f$ is known
 * as the complete elliptic integral of first kind. Similarly, \f$u(1,m'))=
 * K'(m')\f$, \f$m'=\sqrt{1-m^{2}}\f$ is called the complementary complete
 * elliptic integral of first kind. Jacobi functions are double periodic with
 * quardratic periods \f$K\f$ and \f$K'\f$.
 *
 * This class provides two sets of methods for computing \f$K,K'\f$, and
 * \f$sn,cn,dn\f$. Useful for computing rational approximation of matrix
 * functions given by Cauchy's integral formula, etc.
 */
class CJacobiEllipticFunctions: public CSGObject
{
#ifdef HAVE_ARPREC
	typedef mp_real Real;
	typedef mp_complex Complex;
#else
	typedef float64_t Real;
	typedef complex128_t Complex;
#endif //HAVE_ARPREC
private:
	static inline Real compute_quarter_period(Real b)
	{
#ifdef HAVE_ARPREC
		const Real eps=mp_real::_eps;
		const Real pi=mp_real::_pi;
#else
		const Real eps=std::numeric_limits<Real>::epsilon();
		const Real pi=M_PI;
#endif //HAVE_ARPREC
		Real a=1.0;
		Real mm=1.0;

		int64_t p=2;
		do
		{
			Real a_new=(a+b)*0.5;
			Real b_new=sqrt(a*b);
			Real c=(a-b)*0.5;
			mm=Real(p)*c*c;
			p<<=1;
			a=a_new;
			b=b_new;
		} while (mm>eps);
		return pi*0.5/a;
	}

	static inline Real poly_six(Real x)
	{
		return (132*pow(x,6)+42*pow(x,5)+14*pow(x,4)+5*pow(x,3)+2*pow(x,2)+x);
	}

public:
	/** Computes the quarter periods (K and K') of Jacobian elliptic functions
	 * (see class description).
	 * @param L
	 * @param K the quarter period (to be computed) on the Real axis
	 * @param Kp the quarter period (to be computed) on the Imaginary axis
	 * computed
	 */
	static void ellipKKp(Real L, Real &K, Real &Kp);

	/** Computes three main Jacobi elliptic functions, \f$sn(u,m)\f$,
	 * \f$cn(u,m)\f$ and \f$dn(u,m)\f$ (see class description).
	 * @param u the elliptic integral of the first kind \f$u(k,m)\f$
	 * @param m the modulus parameter, \f$0\le m \le 1\f$
	 * @param sn Jacobi elliptic function sn(u,m)
	 * @param cn Jacobi elliptic function cn(u,m)
	 * @param dn Jacobi elliptic function dn(u,m)
	 */
	static void ellipJC(Complex u, Real m, Complex &sn, Complex &cn,
		Complex &dn);

#ifdef HAVE_ARPREC
	/** Wrapper method for ellipKKp if ARPREC is present (for high precision)
	 * @param L
	 * @param K the quarter period (to be computed) on the Real axis
	 * @param Kp the quarter period (to be computed) on the Imaginary axis
	 * computed
	 */
	static void ellipKKp(float64_t L, float64_t &K, float64_t &Kp)
	{
		mp::mp_init(100, NULL, true);
		mp_real _K, _Kp;
		ellipKKp(mp_real(L), _K, _Kp);
		K=dble(_K);
		Kp=dble(_Kp);
		mp::mp_finalize();
	}

	/** Wrapper method for ellipJC if ARPREC is present (for high precision)
	 * @param u the elliptic integral of the first kind \f$u(k,m)\f$
	 * @param m the modulus parameter, \f$0\le m \le 1\f$
	 * @param sn Jacobi elliptic function sn(u,m)
	 * @param cn Jacobi elliptic function cn(u,m)
	 * @param dn Jacobi elliptic function dn(u,m)
	 */
	static void ellipJC(complex128_t u, float64_t m,
		complex128_t &sn, complex128_t &cn, complex128_t &dn)
	{
		mp::mp_init(100, NULL, true);
		mp_complex _sn, _cn, _dn;
		ellipJC(mp_complex(u.real(),u.imag()), mp_real(m), _sn, _cn, _dn);
		sn=complex128_t(dble(_sn.real),dble(_sn.imag));
		cn=complex128_t(dble(_cn.real),dble(_cn.imag));
		dn=complex128_t(dble(_dn.real),dble(_dn.imag));
		mp::mp_finalize();
	}
#endif //HAVE_ARPREC

	/** @return object name */
	virtual const char* get_name() const
	{
		return "JacobiEllipticFunctions";
	}
};

}

#endif /* JACOBI_ELLIPTIC_FUNCTIONS_H_ */