Skip to content

Commit 7be8297

Browse files
authored
style: remove assignment duplication
Signed-off-by: Athan <kgryte@gmail.com>
1 parent d107953 commit 7be8297

File tree

1 file changed

+39
-42
lines changed
  • lib/node_modules/@stdlib/blas/ext/base/gvander/lib

1 file changed

+39
-42
lines changed

lib/node_modules/@stdlib/blas/ext/base/gvander/lib/accessors.js

Lines changed: 39 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -85,33 +85,31 @@ function gvander( mode, M, N, x, sx, ox, out, so1, so2, oo ) {
8585
// Note on variable naming convention: S#, do#, io, i# where # corresponds to the loop number, with `0` being the innermost loop...
8686
isrm = isRowMajor( [ so1, so2 ] );
8787

88-
if ( isrm && mode > 0 ) {
89-
// Row-major, increasing: x^0, x^1, ..., x^(N-1)
88+
if ( isrm ) {
9089
S0 = N;
9190
S1 = M;
9291
do0 = so2;
9392
do1 = so1 - ( S0*so2 );
94-
io = oo;
95-
ix = ox;
96-
for ( i1 = 0; i1 < S1; i1++ ) {
97-
v = xget( xbuf, ix );
98-
oset( obuf, io, 1.0 );
99-
tmp = 1.0;
100-
io += do0;
101-
for ( i0 = 1; i0 < S0; i0++ ) {
102-
tmp *= v;
103-
oset( obuf, io, tmp );
93+
if ( mode > 0 ) {
94+
// Increasing: x^0, x^1, ..., x^(N-1)
95+
io = oo;
96+
ix = ox;
97+
for ( i1 = 0; i1 < S1; i1++ ) {
98+
v = xget( xbuf, ix );
99+
oset( obuf, io, 1.0 );
100+
tmp = 1.0;
104101
io += do0;
102+
for ( i0 = 1; i0 < S0; i0++ ) {
103+
tmp *= v;
104+
oset( obuf, io, tmp );
105+
io += do0;
106+
}
107+
ix += sx;
108+
io += do1;
105109
}
106-
ix += sx;
107-
io += do1;
110+
return obuf;
108111
}
109-
} else if ( isrm ) {
110-
// Row-major, decreasing: x^(N-1), x^(N-2), ..., x^0
111-
S0 = N;
112-
S1 = M;
113-
do0 = so2;
114-
do1 = so1 - ( S0*so2 );
112+
// Decreasing: x^(N-1), x^(N-2), ..., x^0
115113
io = oo + ( ( S1-1 ) * so1 ) + ( ( S0-1 ) * so2 );
116114
ix = ox + ( ( S1-1 ) * sx );
117115
for ( i1 = S1-1; i1 >= 0; i1-- ) {
@@ -127,12 +125,15 @@ function gvander( mode, M, N, x, sx, ox, out, so1, so2, oo ) {
127125
ix -= sx;
128126
io -= do1;
129127
}
130-
} else if ( mode > 0 ) {
131-
// Column-major, increasing: column j contains x^j
132-
S0 = M;
133-
S1 = N;
134-
do0 = so1;
135-
do1 = so2 - ( S0*so1 );
128+
return obuf;
129+
}
130+
// Column-major...
131+
S0 = M;
132+
S1 = N;
133+
do0 = so1;
134+
do1 = so2 - ( S0*so1 );
135+
if ( mode > 0 ) {
136+
// Increasing: column j contains x^j
136137
io = oo;
137138
gfill( S0, 1.0, obuf, do0, io );
138139
io += so2;
@@ -145,23 +146,19 @@ function gvander( mode, M, N, x, sx, ox, out, so1, so2, oo ) {
145146
}
146147
io += do1;
147148
}
148-
} else {
149-
// Column-major, decreasing: column 0 contains x^(N-1), last column all ones
150-
S0 = M;
151-
S1 = N;
152-
do0 = so1;
153-
do1 = so2 - ( S0*so1 );
154-
gfill( S0, 1.0, obuf, so1, oo + ( ( S1-1 ) * so2 ) );
155-
io = oo + ( ( S1-2 ) * so2 ) + ( ( S0-1 ) * so1 );
156-
for ( i1 = S1-2; i1 >= 0; i1-- ) {
157-
ix = ox + ( ( S0-1 ) * sx );
158-
for ( i0 = S0-1; i0 >= 0; i0-- ) {
159-
oset( obuf, io, oget( obuf, io + so2 ) * xget( xbuf, ix ) );
160-
ix -= sx;
161-
io -= do0;
162-
}
163-
io -= do1;
149+
return obuf;
150+
}
151+
// Decreasing: column 0 contains x^(N-1), last column all ones
152+
gfill( S0, 1.0, obuf, so1, oo + ( ( S1-1 ) * so2 ) );
153+
io = oo + ( ( S1-2 ) * so2 ) + ( ( S0-1 ) * so1 );
154+
for ( i1 = S1-2; i1 >= 0; i1-- ) {
155+
ix = ox + ( ( S0-1 ) * sx );
156+
for ( i0 = S0-1; i0 >= 0; i0-- ) {
157+
oset( obuf, io, oget( obuf, io + so2 ) * xget( xbuf, ix ) );
158+
ix -= sx;
159+
io -= do0;
164160
}
161+
io -= do1;
165162
}
166163
return obuf;
167164
}

0 commit comments

Comments
 (0)