@@ -43,6 +43,7 @@ tape( 'the function has an arity of 7', function test( t ) {
4343 t . end ( ) ;
4444} ) ;
4545
46+ // Expected values determined via the reference Fortran routines in LAPACK:
4647tape ( 'the function returns expected values when calculating the one-norm of a square matrix for N = 1' , function test ( t ) {
4748 var expectedISAVE ;
4849 var expectedKASE ;
@@ -69,16 +70,29 @@ tape( 'the function returns expected values when calculating the one-norm of a s
6970
7071 work = new Float64Array ( 1 ) ;
7172
73+ // Start the estimation with `KASE` = 0:
7274 while ( true ) {
7375 dlacn2 ( 1 , V , X , ISGN , EST , KASE , ISAVE ) ;
7476
7577 if ( KASE [ 0 ] === 0 ) {
78+ // Estimation is complete:
7679 break ;
77- }
78- else if ( KASE [ 0 ] === 1 ) {
80+ } else if ( KASE [ 0 ] === 1 ) {
81+ /*
82+ * - If `KASE` == 1: `dlacn2` wants us to compute A * X and overwrite X.
83+ * - `dgemv` performs the matrix-vector product: work = A * X.
84+ * - A workspace array is necessary here because of the function signature of `dgemv`.
85+ * - `dcopy` copies work into X, so that the updated X is passed back to `dlacn2`.
86+ */
7987 dgemv ( 'row-major' , 'no-transpose' , 1 , 1 , 1.0 , A , 1 , X , 1 , 0 , work , 1 ) ;
8088 dcopy ( 1 , work , 1 , X , 1 ) ;
8189 } else if ( KASE [ 0 ] === 2 ) {
90+ /*
91+ * - If `KASE` == 2: `dlacn2` wants us to compute A ^ T * X and overwrite X.
92+ * - `dgemv` performs the matrix-vector product: work = A ^ T * X.
93+ * - A workspace array is necessary here because of the function signature of `dgemv`.
94+ * - `dcopy` copies work into X, so that the updated X is passed back to `dlacn2`.
95+ */
8296 dgemv ( 'row-major' , 'transpose' , 1 , 1 , 1.0 , A , 1 , X , 1 , 0 , work , 1 ) ;
8397 dcopy ( 1 , work , 1 , X , 1 ) ;
8498 }
@@ -130,16 +144,29 @@ tape( 'the function returns expected values when calculating the one-norm of a s
130144
131145 work = new Float64Array ( 4 ) ;
132146
147+ // Start the estimation with `KASE` = 0:
133148 while ( true ) {
134149 dlacn2 ( 4 , V , X , ISGN , EST , KASE , ISAVE ) ;
135150
136151 if ( KASE [ 0 ] === 0 ) {
152+ // Estimation is complete:
137153 break ;
138- }
139- else if ( KASE [ 0 ] === 1 ) {
154+ } else if ( KASE [ 0 ] === 1 ) {
155+ /*
156+ * - If `KASE` == 1: `dlacn2` wants us to compute A * X and overwrite X.
157+ * - `dgemv` performs the matrix-vector product: work = A * X.
158+ * - A workspace array is necessary here because of the function signature of `dgemv`.
159+ * - `dcopy` copies work into X, so that the updated X is passed back to `dlacn2`.
160+ */
140161 dgemv ( 'row-major' , 'no-transpose' , 4 , 4 , 1.0 , A , 4 , X , 1 , 0 , work , 1 ) ;
141162 dcopy ( 4 , work , 1 , X , 1 ) ;
142163 } else if ( KASE [ 0 ] === 2 ) {
164+ /*
165+ * - If `KASE` == 2: `dlacn2` wants us to compute A ^ T * X and overwrite X.
166+ * - `dgemv` performs the matrix-vector product: work = A ^ T * X.
167+ * - A workspace array is necessary here because of the function signature of `dgemv`.
168+ * - `dcopy` copies work into X, so that the updated X is passed back to `dlacn2`.
169+ */
143170 dgemv ( 'row-major' , 'transpose' , 4 , 4 , 1.0 , A , 4 , X , 1 , 0 , work , 1 ) ;
144171 dcopy ( 4 , work , 1 , X , 1 ) ;
145172 }
@@ -191,16 +218,29 @@ tape( 'the function returns expected values when calculating the one-norm of a s
191218
192219 work = new Float64Array ( 4 ) ;
193220
221+ // Start the estimation with `KASE` = 0:
194222 while ( true ) {
195223 dlacn2 ( 4 , V , X , ISGN , EST , KASE , ISAVE ) ;
196224
197225 if ( KASE [ 0 ] === 0 ) {
226+ // Estimation is complete:
198227 break ;
199- }
200- else if ( KASE [ 0 ] === 1 ) {
228+ } else if ( KASE [ 0 ] === 1 ) {
229+ /*
230+ * - If `KASE` == 1: `dlacn2` wants us to compute A * X and overwrite X.
231+ * - `dgemv` performs the matrix-vector product: work = A * X.
232+ * - A workspace array is necessary here because of the function signature of `dgemv`.
233+ * - `dcopy` copies work into X, so that the updated X is passed back to `dlacn2`.
234+ */
201235 dgemv ( 'row-major' , 'no-transpose' , 4 , 4 , 1.0 , A , 4 , X , 1 , 0 , work , 1 ) ;
202236 dcopy ( 4 , work , 1 , X , 1 ) ;
203237 } else if ( KASE [ 0 ] === 2 ) {
238+ /*
239+ * - If `KASE` == 2: `dlacn2` wants us to compute A ^ T * X and overwrite X.
240+ * - `dgemv` performs the matrix-vector product: work = A ^ T * X.
241+ * - A workspace array is necessary here because of the function signature of `dgemv`.
242+ * - `dcopy` copies work into X, so that the updated X is passed back to `dlacn2`.
243+ */
204244 dgemv ( 'row-major' , 'transpose' , 4 , 4 , 1.0 , A , 4 , X , 1 , 0 , work , 1 ) ;
205245 dcopy ( 4 , work , 1 , X , 1 ) ;
206246 }
0 commit comments