Skip to content

Commit b0e6f6a

Browse files
committed
rename nq to q
1 parent b6fefef commit b0e6f6a

File tree

16 files changed

+373
-373
lines changed

16 files changed

+373
-373
lines changed

c/example/example3.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This is a translation of example 3 from the ODRPACK95 documentation.
99
#include "../include/odrpack/odrpack.h"
1010

1111
// User-supplied function for evaluating the model
12-
void fcn(const int *n, const int *m, const int *np, const int *nq,
12+
void fcn(const int *n, const int *m, const int *np, const int *q,
1313
const double beta[], const double xplusd[],
1414
const int ifixb[], const int ifixx[], const int *ldifx, const int *ideval,
1515
double f[], double fjacb[], double fjacd[], int *istop) {
@@ -47,12 +47,12 @@ int main() {
4747
#define NP 5
4848
#define N 23
4949
#define M 1
50-
#define NQ 2
50+
#define Q 2
5151

5252
// Variable declarations
53-
int n = N, m = M, np = NP, nq = NQ;
54-
int ldwe = N, ld2we = NQ, ldwd = N, ld2wd = M, ldifx = N;
55-
double beta[NP], x[M][N], y[NQ][N], delta[M][N], wd[M][M][N], we[NQ][NQ][N];
53+
int n = N, m = M, np = NP, q = Q;
54+
int ldwe = N, ld2we = Q, ldwd = N, ld2wd = M, ldifx = N;
55+
double beta[NP], x[M][N], y[Q][N], delta[M][N], wd[M][M][N], we[Q][Q][N];
5656
int ifixx[M][N];
5757
int ifixb[NP] = {1, 1, 1, 1, 1};
5858
int iscan = 0;
@@ -85,7 +85,7 @@ int main() {
8585
return 1;
8686
}
8787
}
88-
for (int j = 0; j < nq; j++) {
88+
for (int j = 0; j < q; j++) {
8989
iscan = fscanf(data_file, "%lf", &y[j][i]);
9090
if (iscan != 1) {
9191
fprintf(stderr, "Error reading y values\n");
@@ -144,7 +144,7 @@ int main() {
144144
int info = 0;
145145

146146
// Compute solution
147-
odr_medium_c(fcn, &n, &m, &np, &nq,
147+
odr_medium_c(fcn, &n, &m, &np, &q,
148148
&ldwe, &ld2we, &ldwd, &ld2wd, &ldifx,
149149
beta,
150150
(double *)y, (double *)x,

c/example/example5.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This is an adaptation of example 5 from the ODRPACK95 documentation.
1010
#include "../include/odrpack/odrpack.h"
1111

1212
// User-supplied function for evaluating the model and its partial derivatives
13-
void fcn(const int *n, const int *m, const int *np, const int *nq,
13+
void fcn(const int *n, const int *m, const int *np, const int *q,
1414
const double beta[], const double xplusd[],
1515
const int ifixb[], const int ifixx[], const int *ldifx, const int *ideval,
1616
double f[], double fjacb[], double fjacd[], int *istop) {
@@ -43,7 +43,7 @@ int main() {
4343
#define NP 2
4444
#define N 4
4545
#define M 1
46-
#define NQ 1
46+
#define Q 1
4747
#define LDWE 1
4848
#define LD2WE 1
4949
#define LDWD 1
@@ -52,16 +52,16 @@ int main() {
5252
#define LDSTPD 1
5353
#define LDSCLD 1
5454

55-
int n = N, m = M, np = NP, nq = NQ;
55+
int n = N, m = M, np = NP, q = Q;
5656
double beta[NP] = {2.0, 0.5};
5757
double lower[NP] = {0.0, 0.0};
5858
double upper[NP] = {10.0, 0.9};
5959
double x[M][N] = {{0.982, 1.998, 4.978, 6.01}};
60-
double y[NQ][N] = {{2.7, 7.4, 148.0, 403.0}};
60+
double y[Q][N] = {{2.7, 7.4, 148.0, 403.0}};
6161
double delta[M][N] = {{0.0, 0.0, 0.0, 0.0}};
6262

6363
int ldwe = LDWE, ld2we = LD2WE, ldwd = LDWD, ld2wd = LD2WD;
64-
double we[NQ][LD2WE][LDWE] = {{{-1.0}}};
64+
double we[Q][LD2WE][LDWE] = {{{-1.0}}};
6565
double wd[M][LD2WE][LDWD] = {{{-1.0}}};
6666

6767
int ldifx = LDIFX;
@@ -88,7 +88,7 @@ int main() {
8888

8989
// Determine workspace requirements
9090
int lwork, liwork;
91-
workspace_dimensions_c(&n, &m, &np, &nq, &isodr, &lwork, &liwork);
91+
workspace_dimensions_c(&n, &m, &np, &q, &isodr, &lwork, &liwork);
9292
// printf("lwork: %d\n", lwork);
9393
// printf("liwork: %d\n", liwork);
9494

@@ -114,7 +114,7 @@ int main() {
114114
lunerr = lunrpt;
115115

116116
// Call odr
117-
odr_long_c(fcn, &n, &m, &np, &nq,
117+
odr_long_c(fcn, &n, &m, &np, &q,
118118
&ldwe, &ld2we, &ldwd, &ld2wd,
119119
&ldifx, &ldstpd, &ldscld,
120120
&lwork, &liwork,
@@ -137,8 +137,8 @@ int main() {
137137
// Get the variable locations within the integer and real work space
138138
iworkidx_t iworkidx;
139139
workidx_t workidx;
140-
loc_iwork_c(&m, &np, &nq, &iworkidx);
141-
loc_rwork_c(&n, &m, &np, &nq, &ldwe, &ld2we, &isodr, &workidx);
140+
loc_iwork_c(&m, &np, &q, &iworkidx);
141+
loc_rwork_c(&n, &m, &np, &q, &ldwe, &ld2we, &isodr, &workidx);
142142

143143
// Print some outputs
144144
printf("info: %d\n", info);

c/include/odrpack/odrpack.h

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,16 @@ ODRPACK_EXTERN void close_file(
3737
* @param n `==>` Number of observations.
3838
* @param m `==>` Number of columns of data in the independent variable.
3939
* @param np `==>` Number of function parameters.
40-
* @param nq `==>` Number of responses per observation.
40+
* @param q `==>` Number of responses per observation.
4141
* @param beta `==>` Array [np] of current parameter values.
4242
* @param xplusd `==>` Array [m][ldn] of current explanatory variable values, i.e., `x + delta`.
4343
* @param ifixb `==>` Array [np] of indicators for fixing parameters `beta`.
4444
* @param ifixx `==>` Array [m][ldifx] of indicators for fixing explanatory variable `x`.
4545
* @param ldifx `==>` Leading dimension of array `ifixx`, `ifixx ∈ {1, n}`
4646
* @param ideval `==>` Indicator for selecting computation to be performed.
47-
* @param f `<==` Array [nq][n] for predicted function values.
48-
* @param fjacb `<==` Array [nq][np][n] for Jacobian with respect to `beta`.
49-
* @param fjacd `<==` Array [nq][m][n] for Jacobian with respect to errors `delta`.
47+
* @param f `<==` Array [q][n] for predicted function values.
48+
* @param fjacb `<==` Array [q][np][n] for Jacobian with respect to `beta`.
49+
* @param fjacd `<==` Array [q][m][n] for Jacobian with respect to errors `delta`.
5050
* @param istop `<==` Integer for stopping condition. Values:
5151
* 0 - current `beta` and `x + delta` were acceptable and values were computed successfully,
5252
* 1 - current `beta` and `x + delta` are not acceptable; ODRPACK95 should select values closer to most recently used values if possible,
@@ -56,7 +56,7 @@ typedef void (*odrpack_fcn_t)(
5656
const int *n,
5757
const int *m,
5858
const int *np,
59-
const int *nq,
59+
const int *q,
6060
const double beta[],
6161
const double xplusd[],
6262
const int ifixb[],
@@ -76,9 +76,9 @@ typedef void (*odrpack_fcn_t)(
7676
* @param n `==>` Number of observations.
7777
* @param m `==>` Number of columns of data in the independent variable.
7878
* @param np `==>` Number of function parameters.
79-
* @param nq `==>` Number of responses per observation.
79+
* @param q `==>` Number of responses per observation.
8080
* @param beta `<=>` Array [np] of function parameters.
81-
* @param y `==>` Array [nq][n] of dependent variable. Unused when the model is implicit.
81+
* @param y `==>` Array [q][n] of dependent variable. Unused when the model is implicit.
8282
* @param x `==>` Array [m][n] of explanatory variable.
8383
* @param delta `<=>` Optional array [m][n] with initial error in the `x` data.
8484
* @param lower `==>` Optional array [np] with lower bound on `beta`.
@@ -90,7 +90,7 @@ ODRPACK_EXTERN void odr_short_c(
9090
const int *n,
9191
const int *m,
9292
const int *np,
93-
const int *nq,
93+
const int *q,
9494
double beta[],
9595
const double y[],
9696
const double x[],
@@ -107,16 +107,16 @@ ODRPACK_EXTERN void odr_short_c(
107107
* @param n `==>` Number of observations.
108108
* @param m `==>` Number of columns of data in the independent variable.
109109
* @param np `==>` Number of function parameters.
110-
* @param nq `==>` Number of responses per observation.
110+
* @param q `==>` Number of responses per observation.
111111
* @param ldwe `==>` Leading dimension of array `we`, `ldwe ∈ {1, n}`.
112-
* @param ld2we `==>` Second dimension of array `we`, `ld2we ∈ {1, nq}`.
112+
* @param ld2we `==>` Second dimension of array `we`, `ld2we ∈ {1, q}`.
113113
* @param ldwd `==>` Leading dimension of array `wd`, `ldwd ∈ {1, n}`.
114114
* @param ld2wd `==>` Second dimension of array `wd`, `ld2wd ∈ {1, m}`.
115115
* @param ldifx `==>` Leading dimension of array `ifixx`, `ldifx ∈ {1, n}`.
116116
* @param beta `<=>` Array [np] of function parameters.
117-
* @param y `==>` Array [nq][n] of dependent variable. Unused when the model is implicit.
117+
* @param y `==>` Array [q][n] of dependent variable. Unused when the model is implicit.
118118
* @param x `==>` Array [m][n] of explanatory variable.
119-
* @param we `==>` Optional array [nq][ld2we][ldwe] with `epsilon` weights.
119+
* @param we `==>` Optional array [q][ld2we][ldwe] with `epsilon` weights.
120120
* @param wd `==>` Optional array [m][ld2wd][ldwd] with `delta` weights.
121121
* @param ifixb `==>` Optional array [np] with values designating whether the elements of `beta` are fixed at their input values or not.
122122
* @param ifixx `==>` Optional array [m][ldifx] with values designating whether the elements of `x` are fixed at their input values or not.
@@ -134,7 +134,7 @@ ODRPACK_EXTERN void odr_medium_c(
134134
const int *n,
135135
const int *m,
136136
const int *np,
137-
const int *nq,
137+
const int *q,
138138
const int *ldwe,
139139
const int *ld2we,
140140
const int *ldwd,
@@ -164,9 +164,9 @@ ODRPACK_EXTERN void odr_medium_c(
164164
* @param n `==>` Number of observations.
165165
* @param m `==>` Number of columns of data in the independent variable.
166166
* @param np `==>` Number of function parameters.
167-
* @param nq `==>` Number of responses per observation.
167+
* @param q `==>` Number of responses per observation.
168168
* @param ldwe `==>` Leading dimension of array `we`, `ldwe ∈ {1, n}`.
169-
* @param ld2we `==>` Second dimension of array `we`, `ld2we ∈ {1, nq}`.
169+
* @param ld2we `==>` Second dimension of array `we`, `ld2we ∈ {1, q}`.
170170
* @param ldwd `==>` Leading dimension of array `wd`, `ldwd ∈ {1, n}`.
171171
* @param ld2wd `==>` Second dimension of array `wd`, `ld2wd ∈ {1, m}`.
172172
* @param ldifx `==>` Leading dimension of array `ifixx`, `ldifx ∈ {1, n}`.
@@ -175,9 +175,9 @@ ODRPACK_EXTERN void odr_medium_c(
175175
* @param lwork `==>` Length of array `work`.
176176
* @param liwork `==>` Length of array `iwork`.
177177
* @param beta `<=>` Array [np] of function parameters.
178-
* @param y `==>` Array [nq][n] of dependent variable. Unused when the model is implicit.
178+
* @param y `==>` Array [q][n] of dependent variable. Unused when the model is implicit.
179179
* @param x `==>` Array [m][n] of explanatory variable.
180-
* @param we `==>` Optional array [nq][ld2we][ldwe] with `epsilon` weights.
180+
* @param we `==>` Optional array [q][ld2we][ldwe] with `epsilon` weights.
181181
* @param wd `==>` Optional array [m][ld2wd][ldwd] with `delta` weights.
182182
* @param ifixb `==>` Optional array [np] with values designating whether the elements of `beta` are fixed at their input values or not.
183183
* @param ifixx `==>` Optional array [m][ldifx] with values designating whether the elements of `x` are fixed at their input values or not.
@@ -206,7 +206,7 @@ ODRPACK_EXTERN void odr_long_c(
206206
const int *n,
207207
const int *m,
208208
const int *np,
209-
const int *nq,
209+
const int *q,
210210
const int *ldwe,
211211
const int *ld2we,
212212
const int *ldwd,
@@ -337,13 +337,13 @@ typedef struct
337337
*
338338
* @param m `==>` Number of columns of data in the explanatory variable.
339339
* @param np `==>` Number of function parameters.
340-
* @param nq `==>` Number of responses per observation.
340+
* @param q `==>` Number of responses per observation.
341341
* @param iworkidx `<==` 0-based indexes of integer work array.
342342
*/
343343
ODRPACK_EXTERN void loc_iwork_c(
344344
const int *m,
345345
const int *np,
346-
const int *nq,
346+
const int *q,
347347
iworkidx_t *iworkidx);
348348

349349
/**
@@ -352,7 +352,7 @@ ODRPACK_EXTERN void loc_iwork_c(
352352
* @param n `==>` Number of observations.
353353
* @param m `==>` Number of columns of data in the explanatory variable.
354354
* @param np `==>` Number of function parameters.
355-
* @param nq `==>` Number of responses per observation.
355+
* @param q `==>` Number of responses per observation.
356356
* @param ldwe `==>` Leading dimension of array `we`.
357357
* @param ld2we `==>` Second dimension of array `we`.
358358
* @param isodr `==>` Variable designating whether the solution is by ODR (`isodr=.true.`) or by OLS (`isodr=.false.`).
@@ -362,7 +362,7 @@ ODRPACK_EXTERN void loc_rwork_c(
362362
const int *n,
363363
const int *m,
364364
const int *np,
365-
const int *nq,
365+
const int *q,
366366
const int *ldwe,
367367
const int *ld2we,
368368
const bool *isodr,
@@ -374,7 +374,7 @@ ODRPACK_EXTERN void loc_rwork_c(
374374
* @param n `==>` Number of observations.
375375
* @param m `==>` Number of columns of data in the explanatory variable.
376376
* @param np `==>` Number of function parameters.
377-
* @param nq `==>` Number of responses per observation.
377+
* @param q `==>` Number of responses per observation.
378378
* @param isodr `==>` Variable designating whether the solution is by ODR (`isodr=.true.`) or by OLS (`isodr=.false.`).
379379
* @param lwork `<==` Length of real `work` array.
380380
* @param liwork `<==` Length of integer `iwork` array.
@@ -383,7 +383,7 @@ ODRPACK_EXTERN void workspace_dimensions_c(
383383
const int *n,
384384
const int *m,
385385
const int *np,
386-
const int *nq,
386+
const int *q,
387387
const bool *isodr,
388388
int *lwork,
389389
int *liwork);

example/example1.f90

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ module example1_model
77
contains
88

99
pure subroutine fcn( &
10-
n, m, np, nq, beta, xplusd, ifixb, ifixx, ldifx, ideval, f, fjacb, fjacd, istop)
10+
n, m, np, q, beta, xplusd, ifixb, ifixx, ldifx, ideval, f, fjacb, fjacd, istop)
1111
!! User-supplied subroutine for evaluating the model.
1212

13-
integer, intent(in) :: ideval, ldifx, m, n, np, nq
13+
integer, intent(in) :: ideval, ldifx, m, n, np, q
1414
integer, intent(in) :: ifixb(np), ifixx(ldifx, m)
1515
real(kind=wp), intent(in) :: beta(np), xplusd(n, m)
16-
real(kind=wp), intent(out) :: f(n, nq), fjacb(n, np, nq), fjacd(n, m, nq)
16+
real(kind=wp), intent(out) :: f(n, q), fjacb(n, np, q), fjacd(n, m, q)
1717
integer, intent(out) :: istop
1818

1919
! Local variables
@@ -29,14 +29,14 @@ pure subroutine fcn( &
2929

3030
! Compute predicted values
3131
if (mod(ideval, 10) >= 1) then
32-
do i = 1, nq
32+
do i = 1, q
3333
f(:, i) = beta(1) + beta(2)*(exp(beta(3)*xplusd(:, 1)) - one)**2
3434
end do
3535
end if
3636

3737
! Compute derivatives with respect to 'beta'
3838
if (mod(ideval/10, 10) >= 1) then
39-
do i = 1, nq
39+
do i = 1, q
4040
fjacb(:, 1, i) = one
4141
fjacb(:, 2, i) = (exp(beta(3)*xplusd(:, 1)) - one)**2
4242
fjacb(:, 3, i) = beta(2)*2*(exp(beta(3)*xplusd(:, 1)) - one)*exp(beta(3)*xplusd(:, 1))*xplusd(:, 1)
@@ -45,7 +45,7 @@ pure subroutine fcn( &
4545

4646
! Compute derivatives with respect to 'delta'
4747
if (mod(ideval/100, 10) >= 1) then
48-
do i = 1, nq
48+
do i = 1, q
4949
fjacd(:, 1, i) = beta(2)*2*(exp(beta(3)*xplusd(:, 1)) - one)*exp(beta(3)*xplusd(:, 1))*beta(3)
5050
end do
5151
end if
@@ -56,14 +56,14 @@ end module example1_model
5656

5757
program example1
5858
!! Explicit ODR job, with user-supplied analytic derivatives and nondefault `ifixx`.
59-
59+
6060
use odrpack, only: odr
6161
use odrpack_kinds, only: wp
6262
use example1_model, only: fcn
6363
implicit none
6464

6565
! Variable declarations
66-
integer :: i, info, iprint, j, job, lundata, lunrpt, m, n, np, nq
66+
integer :: i, info, iprint, j, job, lundata, lunrpt, m, n, np, q
6767
integer, allocatable :: ifixx(:, :)
6868
real(kind=wp), allocatable :: beta(:), x(:, :), y(:, :)
6969

@@ -72,15 +72,15 @@ program example1
7272

7373
! Read problem dimensions
7474
open (newunit=lundata, file='./example/data1.dat')
75-
read (lundata, *) n, m, np, nq
75+
read (lundata, *) n, m, np, q
7676

7777
! Allocate arrays
78-
allocate (beta(np), x(n, m), y(n, nq), ifixx(n, m))
78+
allocate (beta(np), x(n, m), y(n, q), ifixx(n, m))
7979

8080
! Read problem data and set nondefault value for argument 'ifixx'
8181
read (lundata, *) (beta(i), i=1, np)
8282
do i = 1, n
83-
read (lundata, *) (x(i, j), j=1, m), (y(i, j), j=1, nq)
83+
read (lundata, *) (x(i, j), j=1, m), (y(i, j), j=1, q)
8484
if (x(i, 1) == 0.0E0_wp .or. x(i, 1) == 100.0E0_wp) then
8585
ifixx(i, 1) = 0
8686
else
@@ -102,7 +102,7 @@ program example1
102102

103103
! Compute solution
104104
call odr(fcn=fcn, &
105-
n=n, m=m, np=np, nq=nq, &
105+
n=n, m=m, np=np, q=q, &
106106
beta=beta, &
107107
y=y, x=x, &
108108
ifixx=ifixx, &

0 commit comments

Comments
 (0)