a simple class for continued fractions introduced

This commit is contained in:
Jiri Pittner 2022-02-17 18:03:47 +01:00
parent c6356c0c76
commit 5544ea4ee7
5 changed files with 92 additions and 2 deletions

View File

@ -1,6 +1,6 @@
lib_LTLIBRARIES = libla.la lib_LTLIBRARIES = libla.la
include_HEADERS = simple.h vecmat3.h quaternion.h fortran.h cuda_la.h auxstorage.h davidson.h laerror.h mat.h qsort.h vec.h bisection.h diis.h la.h noncblas.h smat.h bitvector.h fourindex.h la_traits.h nonclass.h sparsemat.h sparsesmat.h csrmat.h conjgrad.h gmres.h matexp.h permutation.h polynomial.h include_HEADERS = simple.h vecmat3.h quaternion.h fortran.h cuda_la.h auxstorage.h davidson.h laerror.h mat.h qsort.h vec.h bisection.h diis.h la.h noncblas.h smat.h bitvector.h fourindex.h la_traits.h nonclass.h sparsemat.h sparsesmat.h csrmat.h conjgrad.h gmres.h matexp.h permutation.h polynomial.h contfrac.h
libla_la_SOURCES = simple.cc quaternion.cc vecmat3.cc vec.cc mat.cc smat.cc sparsemat.cc sparsesmat.cc csrmat.cc laerror.cc noncblas.cc bitvector.cc strassen.cc nonclass.cc cuda_la.cc fourindex.cc permutation.cc polynomial.cc libla_la_SOURCES = simple.cc quaternion.cc vecmat3.cc vec.cc mat.cc smat.cc sparsemat.cc sparsesmat.cc csrmat.cc laerror.cc noncblas.cc bitvector.cc strassen.cc nonclass.cc cuda_la.cc fourindex.cc permutation.cc polynomial.cc contfrac.cc
check_PROGRAMS = t test check_PROGRAMS = t test
t_SOURCES = t.cc t2.cc t_SOURCES = t.cc t2.cc
test_SOURCES = test.cc test_SOURCES = test.cc

43
contfrac.cc Normal file
View File

@ -0,0 +1,43 @@
/*
LA: linear algebra C++ interface library
Copyright (C) 2022 Jiri Pittner <jiri.pittner@jh-inst.cas.cz> or <jiri@pittnerovi.com>
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.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "contfrac.h"
#include <stdio.h>
#include <string.h>
#include <math.h>
namespace LA {
/***************************************************************************//**
* forced instantization in the corresponding object file
******************************************************************************/
template class ContFrac<int>;
template class ContFrac<unsigned int>;
#define INSTANTIZE(T) \
INSTANTIZE(int)
INSTANTIZE(unsigned int)
}//namespace

45
contfrac.h Normal file
View File

@ -0,0 +1,45 @@
/*
LA: linear algebra C++ interface library
Copyright (C) 2022 Jiri Pittner <jiri.pittner@jh-inst.cas.cz> or <jiri@pittnerovi.com>
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.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _CONTFRAC_H
#define _CONTFRAC_H
#include "la_traits.h"
#include "vec.h"
namespace LA {
template <typename T>
class ContFrac : public NRVec<T> {
public:
ContFrac(): NRVec<T>() {};
template<int SIZE> ContFrac(const T (&a)[SIZE]) : NRVec<T>(a) {};
ContFrac(const NRVec<T> &v) : NRVec<T>(v) {}; //allow implicit conversion from NRVec
ContFrac(const int n) : NRVec<T>(n+1) {};
int length() const {return NRVec<T>::size()-1;};
void resize(const int n, const bool preserve=true) {NRVec<T>::resize(n+1,preserve);}
};
}//namespace
#endif

1
la.h
View File

@ -42,6 +42,7 @@
#include "csrmat.h" #include "csrmat.h"
#include "vec.h" #include "vec.h"
#include "polynomial.h" #include "polynomial.h"
#include "contfrac.h"
using namespace LA; using namespace LA;
typedef NRMat<int> NRIMat; typedef NRMat<int> NRIMat;

1
t.cc
View File

@ -24,6 +24,7 @@
#include "quaternion.h" #include "quaternion.h"
#include "permutation.h" #include "permutation.h"
#include "polynomial.h" #include "polynomial.h"
#include "contfrac.h"
#include "simple.h" #include "simple.h"
using namespace std; using namespace std;