gtkIOStream  1.7.0
GTK+ << C++ IOStream operators for GTK+. Now with ORBing, numerical computation, audio client and more ...
DeBoor.C
Go to the documentation of this file.
1 /* Copyright 2000-2018 Matt Flax <flatmax@flatmax.org>
2  This file is part of GTK+ IOStream class set
3 
4  GTK+ IOStream is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  GTK+ IOStream is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You have received a copy of the GNU General Public License
15  along with GTK+ IOStream
16  */
17 #include "DeBoor.H"
18 
19 #include <iostream>
20 using namespace std;
21 
22 #include <stdio.h>
23 
24 extern "C" {
25  void bsplpp_(float *t, float *bcoef,int *n, int *k, float scrtch[][4], float *breakp, float coef[][4], int *l);
26  float smooth_(float *x, float *y, float *dy, int *npoint, float *s, float v[][7], float a[][4]);
27  void csaps_(float *x, float *y, float *dy, int *npoint, float *s, float *result);
28 }
29 
31  v=a=NULL;
32  N=0;
33  float t[11]= {0., 0., 0., 0., 1., 3., 4., 6., 6., 6., 6.};
34  float bcoef[7] = {0., 0., 0., 1., 0., 0., 0.};
35 
36  int n=7, k=4;
37  float scrtch[4][4];
38  bsplpp_(t,bcoef,&n,&k,scrtch,breakp,coef,&l);
39  cout<<"breakp : ";
40  for (int i=0; i<5; i++)
41  cout<<breakp[i]<<'\t';
42  cout<<endl;
43  cout<<"coef : ";
44  for (int i=0; i<4; i++)
45  for (int j=0; j<4; j++)
46  cout<<coef[j][i]<<'\t';
47  cout<<endl;
48  cout<<"l : "<<l<<endl;
49 }
50 
51 void DeBoor::deleteMatrix(float **m) {
52  cout<<N<<endl;
53  cout<<m<<endl;
54  if (m) {
55  cout<<m<<endl;
56  for (int i=0; i<N; i++) {
57  cout<<i<<endl;
58  if (m[i]) {
59  cout<<m[i]<<endl;
60  delete [] m[i];
61  cout<<i<<endl;
62  m[i]=NULL;
63  cout<<i<<endl;
64  }
65  }
66  delete [] m;
67  m=NULL;
68  }
69 }
70 
72  cout<<"DeBoor::deleteMatrices"<<endl;
73  deleteMatrix(v);
74  deleteMatrix(a);
75 }
76 
78  deleteMatrices();
79 }
80 
81 
82 float **&DeBoor::createMatrix(int k) {
83  float **m=NULL;
84  cout<<"DeBoor::createMatrix, k="<<k<<endl;
85  m=new float*[N];
86  if (m) {
87  for (int i=0; i<N; i++)
88  m[i]=NULL;
89  for (int i=0; i<N; i++) {
90  m[i]=new float[k];
91  if (!m[i]) {
92  deleteMatrix(m);
93  break;
94  }
95  cout<<m[i]<<endl;
96  }
97  }
98  return m;
99 }
100 
102  if (N<n) {
103  deleteMatrices();
104  N=n;
105  v=createMatrix(7);
106  a=createMatrix(4);
107  }
108 }
109 
110 //void DeBoor::csapsOrig(float *x, float *y, float *dy, int n, float p) {
111 // createMatrices(n);
116 // cout<<v<<endl;
117 // cout<<a<<endl;
118 // if (v && a) {
119 // float ret=smooth_(x, y, dy, &n, &p, (float (*)[7])&v[0], (float (*)[4])&a[0]);
120 // } else
121 // printf("DeBoor::csaps : memory error\n");
122 //}
123 
124 void DeBoor::csaps(float *x, float *y, float *dy, int n, float s) {
125  if (resultCSAPS.size()<n)
126  resultCSAPS.resize(n);
127  csaps_(x, y, dy, &n, &s, &resultCSAPS[0]);
128  cout<<"y, results"<<endl;
129  for (int i=0; i<n; i++)
130  cout<<y[i]<<'\t'<<resultCSAPS[i]<<'\n';
131 }
132 
133 float DeBoor::operator[](int i){
134  if (i<resultCSAPS.size() && i>0)
135  return resultCSAPS[i];
136 }
float * x
float * result
int N
void deleteMatrix(float **m)
Definition: DeBoor.C:51
STL namespace.
float smooth_(float *x, float *y, float *dy, int *npoint, float *s, float v[][7], float a[][4])
float **& createMatrix(int k)
Definition: DeBoor.C:82
void csaps_(float *x, float *y, float *dy, int *npoint, float *s, float *result)
void csaps(float *x, float *y, float *dy, int n, float s)
Definition: DeBoor.C:124
virtual ~DeBoor()
Definition: DeBoor.C:77
void bsplpp_(float *t, float *bcoef, int *n, int *k, float scrtch[][4], float *breakp, float coef[][4], int *l)
void createMatrices(int n)
Definition: DeBoor.C:101
float * y
DeBoor()
Definition: DeBoor.C:30
void deleteMatrices()
Delete memory.
Definition: DeBoor.C:71
float * dy
float operator[](int i)
Definition: DeBoor.C:133
gtkIOStream: /tmp/gtkiostream/src/deBoor/DeBoor.C Source File
GTK+ IOStream  Beta