Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

  • ecd6f1f
  • /
  • inst
  • /
  • include
  • /
  • splines.h
Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
content badge
swh:1:cnt:84fa8448befa5de56f81111f4248e1de455d7949
directory badge
swh:1:dir:ae9e93f86155d317108334c36b6d64bb5271a5ea

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
splines.h
#ifndef SPLINES_H
#define SPLINES_H

#include <RcppArmadillo.h>

namespace rstpm2 {

  /* arma::mat qr_q(const arma::mat& X, double tol = 1E-12); */
      
  class SplineBasis {
  public:
    int order,			/* order of the spline */
      ordm1,			/* order - 1 (3 for cubic splines) */
      nknots,			/* number of knots */
      curs,			/* current position in knots vector */
      boundary,		/* must have knots[(curs) <= x < knots(curs+1) */
      ncoef;			/* number of coefficients */
    /* except for the boundary case */
    arma::vec ldel;  	/* differences from knots on the left */
    arma::vec rdel;	/* differences from knots on the right */
    arma::vec knots;	/* knot vector */
    arma::vec coeff;	/* coefficients */
    arma::vec a;		/* scratch array */
    SplineBasis(int order = 4);
    SplineBasis(arma::vec knots, int order = 4);
    int set_cursor(double x);
    void diff_table(double x, int ndiff);
    double slow_evaluate(double x, int nder);
    /* fast evaluation of basis functions */
    arma::vec basis_funcs(double x);
    arma::vec eval(double x, int ders=0);
    arma::mat basis(arma::vec x, int ders=0);
  };
  
  class bs : public SplineBasis {
  public:
    arma::vec boundary_knots, interior_knots;
    int intercept, df;
    bs(); // default constructor
    bs(arma::vec boundary_knots, arma::vec interior_knots, int intercept = 0);
    arma::vec eval(double x, int ders=0);
    arma::mat basis(arma::vec x, int ders=0);
  };

  class ns : public bs {
  public:
    arma::vec tl0, tl1, tr0, tr1;
    arma::mat q_matrix;
    int cure;
    ns(); // default constructor
    // ns(vec boundary_knots, vec interior_knots, int intercept=0) :
    //   bs(boundary_knots, interior_knots, intercept) {
    //   // calculate the Q matrix
    //   mat const_basis = bs::basis(boundary_knots, 2);
    //   mat qd = qr_q(const_basis.t());
    //   mat qsub(qd.n_rows, qd.n_cols-2);
    //   for (size_t i=0; i<qsub.n_rows; i++)
    // 	for (size_t j=0; j<qsub.n_cols; j++)
    // 	  qsub(i,j) = qd(i,j+2);
    //   q_matrix = qsub.t();
    //   tl0 = q_matrix * bs::eval(boundary_knots(0), 0);
    //   tl1 = q_matrix * bs::eval(boundary_knots(0), 1);
    //   tr0 = q_matrix * bs::eval(boundary_knots(1), 0);
    //   tr1 = q_matrix * bs::eval(boundary_knots(1), 1);
    // }
    ns(arma::vec boundary_knots, arma::vec interior_knots, arma::mat _q_matrix,
       int intercept=0, int cure=0);
    arma::vec eval(double x, int der);
    arma::mat basis(arma::vec x, int ders=0);
  }; // class ns

} // namespace rstpm2

#endif /* splines.h */

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API