1
1
/* Copyright (C) 2009 Carlo de Falco
3
This program is free software; you can redistribute it and/or modify
3
This program is free software: you can redistribute it and/or modify
4
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; either version 2 of the License, or
5
the Free Software Foundation, either version 2 of the License, or
6
6
(at your option) any later version.
8
8
This program is distributed in the hope that it will be useful,
9
9
but WITHOUT ANY WARRANTY; without even the implied warranty of
10
10
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
11
GNU General Public License for more details.
13
13
You should have received a copy of the GNU General Public License
14
along with this program; if not, write to the Free Software
15
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
14
along with this program. If not, see <http://www.gnu.org/licenses/>.
18
17
#include <octave/oct.h>
19
18
#include "low_level_functions.h"
21
21
static bool bspeval_bad_arguments(const octave_value_list& args);
40
40
p - Evaluated points, matrix of size (dim,nu)\n\
46
int d = args(0).int_value();
47
const Matrix c = args(1).matrix_value();
48
const RowVector k = args(2).row_vector_value();
49
const NDArray u = args(3).array_value();
51
octave_idx_type nu = u.length();
52
octave_idx_type mc = c.rows(),
55
Matrix p(mc, nu, 0.0);
58
44
octave_value_list retval;
61
if (nc + d == k.length() - 1)
66
for (octave_idx_type col(0); col<nu; col++)
68
s = findspan(nc-1, d, u(col), k);
69
basisfun(s, u(col), d, k, N);
71
for (octave_idx_type row(0); row<mc; row++)
74
for ( octave_idx_type i(0); i<=d; i++)
75
tmp2 += N(i)*c(row,tmp1+i);
82
error("inconsistent bspline data, d + columns(c) != length(k) - 1.");
85
retval(0) = octave_value(p);
45
if (!bspeval_bad_arguments (args))
47
int d = args(0).int_value();
48
const Matrix c = args(1).matrix_value();
49
const RowVector k = args(2).row_vector_value();
50
const NDArray u = args(3).array_value();
52
octave_idx_type nu = u.length();
53
octave_idx_type mc = c.rows(),
56
Matrix p(mc, nu, 0.0);
60
if (nc + d == k.length() - 1)
62
#pragma omp parallel default (none) shared (d, c, k, u, nu, mc, nc, p)
68
for (octave_idx_type col=0; col<nu; col++)
70
//printf ("thread %d, col %d\n", omp_get_thread_num (), col);
71
s = findspan (nc-1, d, u(col), k);
72
basisfun (s, u(col), d, k, N);
74
for (octave_idx_type row(0); row<mc; row++)
77
for ( octave_idx_type i(0); i<=d; i++)
78
tmp2 += N(i)*c(row,tmp1+i);
86
error("inconsistent bspline data, d + columns(c) != length(k) - 1.");
88
retval(0) = octave_value(p);
89
static bool bspeval_bad_arguments(const octave_value_list& args)
94
static bool bspeval_bad_arguments (const octave_value_list& args)
91
96
if (args.length() != 4)
93
error("wrong number of input arguments.");
98
error("bspeval: wrong number of input arguments.");
96
101
if (!args(0).is_real_scalar())
98
error("degree should be a scalar.");
103
error("bspeval: degree should be a scalar.");
101
106
if (!args(1).is_real_matrix())
103
error("the control net should be a matrix of doubles.");
108
error("bspeval: the control net should be a matrix of doubles.");
106
111
if (!args(2).is_real_matrix())
108
error("the knot vector should be a real vector.");
113
error("bspeval: the knot vector should be a real vector.");
111
116
if (!args(3).is_real_type())
113
error("the set of parametric points should be an array of doubles.");
118
error("bspeval: the set of parametric points should be an array of doubles.");