INGOR
ytBSpline.h
1/*
2 math/ytBSpline.{h,c} : B-spline routines.
3 Copyright (C) 2018, Yoshinori Tamada <tamada A T ytlab.jp>
4 All rights reserved.
5
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions
8 are met:
9
10 * Redistributions of source code must retain the above copyright
11 notice, this list of conditions and the following disclaimer.
12
13 * Redistributions in binary form must reproduce the above copyright
14 notice, this list of conditions and the following disclaimer in
15 the documentation and/or other materials provided with the
16 distribution.
17
18 * Neither the name of Kyoto University nor the names of its
19 contributors may be used to endorse or promote products derived
20 from this software without specific prior written permission.
21
22 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26 COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 POSSIBILITY OF SUCH DAMAGE.
34*/
35
36#ifndef __YTLIB_BSPLINE_H
37#define __YTLIB_BSPLINE_H
38
39#include <stdio.h>
40
41void ytBSpline_designMatrix(const double * x, const int n,
42 const double xl, const double xr,
43 double * B, int * index,
44 const int ndx, const int degree, double * work);
45void ytBSpline_designMatrix2(const double * x, const int n, double * B, int * index,
46 const int ndx, const int degree, double * work);
47void ytBSpline_Dk(const int m, const int k, double * D);
48void ytBSpline_K(int m, int k, double * K, double * work);
49double ytBSpline_det_K_plus(const double * K, const int m);
50void ytBSpline_syBtB(const double * B, const int * index, const int n,
51 const int ndx, const int degree, double * BtB);
52void ytBSpline_syBtB2(const double * B, const int * index, const int n,
53 const int ndx, const int degree, double * BtB);
54void ytBSpline_dsycopy(const double * X, double * Y, int m);
55void ytBSpline_dsycopy20(const double * X, double * Y);
56void ytBSpline_syMBt(const double * restrict A,
57 const double * restrict B, const int* index,
58 const int n, const int ndx, const int degree,
59 double * restrict C);
60void ytBSpline_dxpy_mask(int n, double * x, const double * y, const char * mask);
61void ytBSpline_dxmy_mask(int n, double * x, const double * y, const char * mask);
62void ytBSpline_Mv(int n, int m, const double * A, const double * b, double * c);
63void ytBSpline_Mv20(int n, const double * A, const double * b, double * c);
64void ytBSpline_Mv20_mask(int n, const double * A, const double * b, double * c, const char * mask);
65void ytBSpline_Bx3(const double * restrict B, const int * index,
66 const double * x, const int n, double * restrict y);
67double ytBSpline_var_mask(int n, const double * T, const double * g,
68 const char * mask);
69double ytBSpline_gKgL(int M, const double * K, const double * g);
70double ytBSpline_gKg20L(const double * K, const double * g);
71void ytBSpline_printB(FILE * fp, const double * B, const int * index,
72 int n, int M, int deg);
73double ytBSpline_gamma20(double x, double xl, double xr, double * gamma);
74#endif /* __YTLIB_BSPLINE_H */
void ytBSpline_designMatrix(const double *x, const int n, const double xl, const double xr, double *B, int *index, const int ndx, const int degree, double *work)
Generates the design matrix for B-spline nonparametric regression.
Definition: ytBSpline.c:206
void ytBSpline_dxpy_mask(int n, double *x, const double *y, const char *mask)
Calculates a vector-vector addition x <- x + y with a mask vector.
Definition: ytBSpline.c:548
void ytBSpline_designMatrix2(const double *x, const int n, double *B, int *index, const int ndx, const int degree, double *work)
Generates the design matrix for B-spline nonparametric regression.
Definition: ytBSpline.c:87
void ytBSpline_Mv20(int n, const double *A, const double *b, double *c)
A b c (M,n) x (n,1) -> (M,1) M=20.
Definition: ytBSpline.c:587
void ytBSpline_K(int m, int k, double *K, double *work)
Calculates Dk' Dk where Dk is the k-th order difference matrix.
Definition: ytBSpline.c:347
void ytBSpline_syBtB(const double *B, const int *index, const int n, const int ndx, const int degree, double *BtB)
Calculates the symmetric matrix of the multiplication B' B using the index vector set by ytBSpline_de...
Definition: ytBSpline.c:414
void ytBSpline_dxmy_mask(int n, double *x, const double *y, const char *mask)
Calculates a vector-vector subtraction x <- x - y with a mask vector.
Definition: ytBSpline.c:562
double ytBSpline_gamma20(double x, double xl, double xr, double *gamma)
Calculates B-splines with its coefficients for a single value.
Definition: ytBSpline.c:814
double ytBSpline_det_K_plus(const double *K, const int m)
Calculates |K|+.
Definition: ytBSpline.c:376
void ytBSpline_printB(FILE *fp, const double *B, const int *index, int n, int ndx, int deg)
Prints the design matrix.
Definition: ytBSpline.c:788
void ytBSpline_dsycopy(const double *X, double *Y, int m)
Copies an upper symmetric matrix.
Definition: ytBSpline.c:462
void ytBSpline_Dk(const int m, const int k, double *D)
Generates k-th order difference matrix.
Definition: ytBSpline.c:317