1 /*
2 * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF ICT,
3 * Applied Mathematics, Norway.
4 *
5 * Contact information: E-mail: tor.dokken@sintef.no
6 * SINTEF ICT, Department of Applied Mathematics,
7 * P.O. Box 124 Blindern,
8 * 0314 Oslo, Norway.
9 *
10 * This file is part of SISL.
11 *
12 * SISL is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Affero General Public License as
14 * published by the Free Software Foundation, either version 3 of the
15 * License, or (at your option) any later version.
16 *
17 * SISL is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Affero General Public License for more details.
21 *
22 * You should have received a copy of the GNU Affero General Public
23 * License along with SISL. If not, see
24 * <http://www.gnu.org/licenses/>.
25 *
26 * In accordance with Section 7(b) of the GNU Affero General Public
27 * License, a covered work must retain the producer line in every data
28 * file that is created or manipulated using SISL.
29 *
30 * Other Usage
31 * You can be released from the requirements of the license by purchasing
32 * a commercial license. Buying such a license is mandatory as soon as you
33 * develop commercial activities involving the SISL library without
34 * disclosing the source code of your own applications.
35 *
36 * This file may be used in accordance with the terms contained in a
37 * written agreement between you and SINTEF ICT.
38 */
39
40 #include "sisl-copyright.h"
41
42 /*
43 *
44 * $Id: s6knotmult.c,v 1.1 1994-04-21 12:10:42 boh Exp $
45 *
46 */
47
48
49 #define S6KNOTMULT
50
51 #include "sislP.h"
52
53 #if defined(SISLNEEDPROTOTYPES)
54 int
s6knotmult(double et[],int ik,int in,int * ileft,double ax,int * jstat)55 s6knotmult(double et[],int ik,int in,int *ileft,double ax,int *jstat)
56 #else
57 int s6knotmult(et,ik,in,ileft,ax,jstat)
58 double et[];
59 int in;
60 int ik;
61 int *ileft;
62 double ax;
63 int *jstat;
64 #endif
65 /*
66 *********************************************************************
67 *
68 *********************************************************************
69 *
70 * PURPOSE : To determine the multiplicity of a knot at a specified
71 * parameter value.
72 *
73 *
74 * INPUT : et - Double array of dimension [in+ik] containing
75 * the knot vector.
76 * ik - The polynomial order of the B-splines associated
77 * with et.
78 * in - The dimension of the spline space associated with
79 * the knot vector et.
80 * ax - The point at which the B-spline values and derivatives
81 * are to be computed.
82 *
83 *
84 *
85 * INPUT/OUTPUT :
86 * ileft - Pointer to the interval in the knot vector
87 * where ax is located, check the relations above.
88 * jstat - Status messages
89 * > 0 : Warning.
90 * = 0 : Ok.
91 * < 0 : Error.
92 *
93 *
94 * METHOD : The aim is to do as little work as possible in the cases
95 * where ileft has the right or almost the right value.
96 * First of all we make sure that ileft has a legal value
97 * (a value in the range ik-1 to in-1). Then we check
98 * if the current value is OK.
99 * If it is not we check that ax is in the interior of et
100 * or if the right value is obtained by either increasing
101 * or decreasing ileft by 1. If the right value still has
102 * not been found we do a binary search.
103 *
104 *
105 * REFERENCES :
106 *
107 *-
108 * CALLS : s1219
109 *
110 * WRITTEN BY : Knut Moerken, University of Oslo, August 1988.
111 *
112 *********************************************************************
113 */
114 {
115 int kpos=0; /* The position of the error. */
116 int kstat; /* Local status variable */
117 int kmult=0; /* Multiplicity of knot */
118 int ki; /* Loop variable */
119
120 /* Localize knot interval */
121
122 s1219(et,ik,in,ileft,ax,&kstat);
123 if (kstat<0) goto error;
124
125 if (et[*ileft] == ax)
126 {
127 kmult = 1;
128 ki = *ileft-1;
129 for (ki=(*ileft)-1; 0 <= ki; ki--)
130 if (et[ki] == ax) kmult++;
131 }
132 if (et[in] == ax)
133 {
134 for (ki=in ; ki<in+ik;ki++)
135 if (et[ki] == ax) kmult++;
136 }
137
138 *jstat = 0;
139 goto out;
140
141 /* Error in lower level function */
142
143 error: *jstat = kstat;
144 s6err("s6knotmult",*jstat,kpos);
145 goto out;
146
147 out:
148 return(kmult);
149 }
150