@@ -25,6 +25,41 @@ var Float64Array = require( '@stdlib/array/float64' );
2525var setReadOnly = require ( '@stdlib/utils/define-nonenumerable-read-only-property' ) ;
2626
2727
28+ // FUNCTIONS //
29+
30+ /**
31+ * Returns a matrix element based on the provided row and column indices.
32+ *
33+ * @private
34+ * @param {integer } i - row index
35+ * @param {integer } j - column index
36+ * @returns {(number|undefined) } matrix element
37+ */
38+ function get ( i , j ) {
39+ /* eslint-disable no-invalid-this */
40+ var idx = this . offset + ( i * this . strides [ 0 ] ) + ( j * this . strides [ 1 ] ) ;
41+ return this . data [ idx ] ;
42+ }
43+
44+ /**
45+ * Sets a matrix element based on the provided row and column indices.
46+ *
47+ * @private
48+ * @param {integer } i - row index
49+ * @param {integer } j - column index
50+ * @param {number } v - value to set
51+ * @returns {Matrix } Matrix instance
52+ */
53+ function set ( i , j , v ) {
54+ /* eslint-disable no-invalid-this */
55+ i = this . offset + ( i * this . strides [ 0 ] ) + ( j * this . strides [ 1 ] ) ;
56+ if ( i >= 0 ) {
57+ this . data [ i ] = v ;
58+ }
59+ return this ;
60+ }
61+
62+
2863// MAIN //
2964
3065/**
@@ -79,38 +114,6 @@ function matrix() {
79114 setReadOnly ( mat , 'get' , get ) ;
80115 setReadOnly ( mat , 'set' , set ) ;
81116 return mat ;
82-
83- /**
84- * Returns a matrix element based on the provided row and column indices.
85- *
86- * @private
87- * @param {integer } i - row index
88- * @param {integer } j - column index
89- * @returns {(number|undefined) } matrix element
90- */
91- function get ( i , j ) {
92- /* eslint-disable no-invalid-this */
93- var idx = this . offset + ( i * this . strides [ 0 ] ) + ( j * this . strides [ 1 ] ) ;
94- return this . data [ idx ] ;
95- }
96-
97- /**
98- * Sets a matrix element based on the provided row and column indices.
99- *
100- * @private
101- * @param {integer } i - row index
102- * @param {integer } j - column index
103- * @param {number } v - value to set
104- * @returns {Matrix } Matrix instance
105- */
106- function set ( i , j , v ) {
107- /* eslint-disable no-invalid-this */
108- i = this . offset + ( i * this . strides [ 0 ] ) + ( j * this . strides [ 1 ] ) ;
109- if ( i >= 0 ) {
110- this . data [ i ] = v ;
111- }
112- return this ;
113- }
114117}
115118
116119
0 commit comments