Skip to content

Commit 1c95092

Browse files
authored
fix: perform float32 emulation in blas/base/srotm
PR-URL: #2445 Reviewed-by: Athan Reines <[email protected]>
1 parent bfd5b70 commit 1c95092

File tree

2 files changed

+34
-24
lines changed

2 files changed

+34
-24
lines changed

lib/node_modules/@stdlib/blas/base/srotm/lib/ndarray.js

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818

1919
'use strict';
2020

21+
// MODULES //
22+
23+
var f32 = require( '@stdlib/number/float64/base/to-float32' );
24+
25+
2126
// MAIN //
2227

2328
/**
@@ -71,8 +76,8 @@ function srotm( N, x, strideX, offsetX, y, strideY, offsetY, param ) {
7176
for ( i = 0; i < N; i++ ) {
7277
w = x[ ix ];
7378
z = y[ ix ];
74-
x[ ix ] = ( w * sh11 ) + ( z * sh12 );
75-
y[ ix ] = ( w * sh21 ) + ( z * sh22 );
79+
x[ ix ] = f32( f32( w * sh11 ) + f32( z * sh12 ) );
80+
y[ ix ] = f32( f32( w * sh21 ) + f32( z * sh22 ) );
7681
ix += strideX;
7782
}
7883
return y;
@@ -83,8 +88,8 @@ function srotm( N, x, strideX, offsetX, y, strideY, offsetY, param ) {
8388
for ( i = 0; i < N; i++ ) {
8489
w = x[ ix ];
8590
z = y[ ix ];
86-
x[ ix ] = w + ( z * sh12 );
87-
y[ ix ] = ( w * sh21 ) + z;
91+
x[ ix ] = f32( w + f32( z * sh12 ) );
92+
y[ ix ] = f32( f32( w * sh21 ) + z );
8893
ix += strideX;
8994
}
9095
return y;
@@ -94,8 +99,8 @@ function srotm( N, x, strideX, offsetX, y, strideY, offsetY, param ) {
9499
for ( i = 0; i < N; i++ ) {
95100
w = x[ ix ];
96101
z = y[ ix ];
97-
x[ ix ] = ( w * sh11 ) + z;
98-
y[ ix ] = -w + ( z * sh22 );
102+
x[ ix ] = f32( f32( w * sh11 ) + z );
103+
y[ ix ] = f32( -w + f32( z * sh22 ) );
99104
ix += strideX;
100105
}
101106
return y;
@@ -108,8 +113,8 @@ function srotm( N, x, strideX, offsetX, y, strideY, offsetY, param ) {
108113
for ( i = 0; i < N; i++ ) {
109114
w = x[ ix ];
110115
z = y[ iy ];
111-
x[ ix ] = ( w * sh11 ) + ( z * sh12 );
112-
y[ iy ] = ( w * sh21 ) + ( z * sh22 );
116+
x[ ix ] = f32( f32( w * sh11 ) + f32( z * sh12 ) );
117+
y[ iy ] = f32( f32( w * sh21 ) + f32( z * sh22 ) );
113118
ix += strideX;
114119
iy += strideY;
115120
}
@@ -121,8 +126,8 @@ function srotm( N, x, strideX, offsetX, y, strideY, offsetY, param ) {
121126
for ( i = 0; i < N; i++ ) {
122127
w = x[ ix ];
123128
z = y[ iy ];
124-
x[ ix ] = w + ( z * sh12 );
125-
y[ iy ] = ( w * sh21 ) + z;
129+
x[ ix ] = f32( w + f32( z * sh12 ) );
130+
y[ iy ] = f32( f32( w * sh21 ) + z );
126131
ix += strideX;
127132
iy += strideY;
128133
}
@@ -133,8 +138,8 @@ function srotm( N, x, strideX, offsetX, y, strideY, offsetY, param ) {
133138
for ( i = 0; i < N; i++ ) {
134139
w = x[ ix ];
135140
z = y[ iy ];
136-
x[ ix ] = ( w * sh11 ) + z;
137-
y[ iy ] = -w + ( z * sh22 );
141+
x[ ix ] = f32( f32( w * sh11 ) + z );
142+
y[ iy ] = f32( -w + f32( z * sh22 ) );
138143
ix += strideX;
139144
iy += strideY;
140145
}

lib/node_modules/@stdlib/blas/base/srotm/lib/srotm.js

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818

1919
'use strict';
2020

21+
// MODULES //
22+
23+
var f32 = require( '@stdlib/number/float64/base/to-float32' );
24+
25+
2126
// MAIN //
2227

2328
/**
@@ -68,8 +73,8 @@ function srotm( N, x, strideX, y, strideY, param ) {
6873
for ( i = 0; i < N; i++ ) {
6974
w = x[ ix ];
7075
z = y[ ix ];
71-
x[ ix ] = ( w * sh11 ) + ( z * sh12 );
72-
y[ ix ] = ( w * sh21 ) + ( z * sh22 );
76+
x[ ix ] = f32( f32( w * sh11 ) + f32( z * sh12 ) );
77+
y[ ix ] = f32( f32( w * sh21 ) + f32( z * sh22 ) );
7378
ix += strideX;
7479
}
7580
return y;
@@ -80,8 +85,8 @@ function srotm( N, x, strideX, y, strideY, param ) {
8085
for ( i = 0; i < N; i++ ) {
8186
w = x[ ix ];
8287
z = y[ ix ];
83-
x[ ix ] = w + ( z * sh12 );
84-
y[ ix ] = ( w * sh21 ) + z;
88+
x[ ix ] = f32( w + f32( z * sh12 ) );
89+
y[ ix ] = f32( f32( w * sh21 ) + z );
8590
ix += strideX;
8691
}
8792
return y;
@@ -91,8 +96,8 @@ function srotm( N, x, strideX, y, strideY, param ) {
9196
for ( i = 0; i < N; i++ ) {
9297
w = x[ ix ];
9398
z = y[ ix ];
94-
x[ ix ] = ( w * sh11 ) + z;
95-
y[ ix ] = -w + ( z * sh22 );
99+
x[ ix ] = f32( f32( w * sh11 ) + z );
100+
y[ ix ] = f32( -w + f32( z * sh22 ) );
96101
ix += strideX;
97102
}
98103
return y;
@@ -115,8 +120,8 @@ function srotm( N, x, strideX, y, strideY, param ) {
115120
for ( i = 0; i < N; i++ ) {
116121
w = x[ ix ];
117122
z = y[ iy ];
118-
x[ ix ] = ( w * sh11 ) + ( z * sh12 );
119-
y[ iy ] = ( w * sh21 ) + ( z * sh22 );
123+
x[ ix ] = f32( f32( w * sh11 ) + f32( z * sh12 ) );
124+
y[ iy ] = f32( f32( w * sh21 ) + f32( z * sh22 ) );
120125
ix += strideX;
121126
iy += strideY;
122127
}
@@ -128,8 +133,8 @@ function srotm( N, x, strideX, y, strideY, param ) {
128133
for ( i = 0; i < N; i++ ) {
129134
w = x[ ix ];
130135
z = y[ iy ];
131-
x[ ix ] = w + ( z * sh12 );
132-
y[ iy ] = ( w * sh21 ) + z;
136+
x[ ix ] = f32( w + f32( z * sh12 ) );
137+
y[ iy ] = f32( f32( w * sh21 ) + z );
133138
ix += strideX;
134139
iy += strideY;
135140
}
@@ -140,8 +145,8 @@ function srotm( N, x, strideX, y, strideY, param ) {
140145
for ( i = 0; i < N; i++ ) {
141146
w = x[ ix ];
142147
z = y[ iy ];
143-
x[ ix ] = ( w * sh11 ) + z;
144-
y[ iy ] = -w + ( z * sh22 );
148+
x[ ix ] = f32( f32( w * sh11 ) + z );
149+
y[ iy ] = f32( -w + f32( z * sh22 ) );
145150
ix += strideX;
146151
iy += strideY;
147152
}

0 commit comments

Comments
 (0)