You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lib/node_modules/@stdlib/blas/ddot/lib/main.js
+3-4Lines changed: 3 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -82,15 +82,14 @@ function ddot( x, y ) {
82
82
}
83
83
opts={
84
84
'dtype': 'float64',
85
-
'casting': 'unsafe',
86
-
'codegen': false
85
+
'casting': 'unsafe'
87
86
};
88
87
x=array(x,opts);
89
88
y=array(y,opts);
90
-
if(x.shape.length!==1){
89
+
if(x.ndims!==1){
91
90
thrownewTypeError('invalid argument. First argument must be either an array-like object or ndarray which can be cast to a 1-dimensional ndarray. Value: `'+x+'`.');
92
91
}
93
-
if(y.shape.length!==1){
92
+
if(y.ndims!==1){
94
93
thrownewTypeError('invalid argument. Second argument must be either an array-like object or ndarray which can be cast to a 1-dimensional ndarray. Value: `'+y+'`.');
@@ -49,7 +49,7 @@ tape( 'the function has an arity of 2', function test( t ) {
49
49
t.end();
50
50
});
51
51
52
-
tape('the function throws an error if provided a first argument which is not a 1-dimensional ndarray',functiontest(t){
52
+
tape('the function throws an error if provided a first argument which is not a 1-dimensional ndarray or array-like object',functiontest(t){
53
53
varvalues;
54
54
vari;
55
55
@@ -60,7 +60,6 @@ tape( 'the function throws an error if provided a first argument which is not a
60
60
false,
61
61
null,
62
62
void0,
63
-
[],
64
63
{},
65
64
functionnoop(){}
66
65
];
@@ -79,30 +78,7 @@ tape( 'the function throws an error if provided a first argument which is not a
79
78
}
80
79
});
81
80
82
-
tape('the function throws an error if provided a first argument which is not a 1-dimensional ndarray containing double-precision floating-point numbers',functiontest(t){
83
-
varvalues;
84
-
vari;
85
-
86
-
values=[
87
-
array(newFloat32Array(10)),
88
-
array(newInt32Array(10))
89
-
];
90
-
91
-
for(i=0;i<values.length;i++){
92
-
t.throws(badValue(values[i]),TypeError,'throws an error when provided '+values[i].toString());
93
-
}
94
-
t.end();
95
-
96
-
functionbadValue(value){
97
-
vary=array(newFloat64Array(10));
98
-
99
-
returnfunctionbadValue(){
100
-
ddot(value,y);
101
-
};
102
-
}
103
-
});
104
-
105
-
tape('the function throws an error if provided a second argument which is not a 1-dimensional ndarray',functiontest(t){
81
+
tape('the function throws an error if provided a second argument which is not a 1-dimensional ndarray or array-like object',functiontest(t){
106
82
varvalues;
107
83
vari;
108
84
@@ -113,7 +89,6 @@ tape( 'the function throws an error if provided a second argument which is not a
113
89
false,
114
90
null,
115
91
void0,
116
-
[],
117
92
{},
118
93
functionnoop(){}
119
94
];
@@ -132,41 +107,54 @@ tape( 'the function throws an error if provided a second argument which is not a
132
107
}
133
108
});
134
109
135
-
tape('the function throws an error if provided a second argument which is not a 1-dimensional ndarray containing double-precision floating-point numbers',functiontest(t){
136
-
varvalues;
137
-
vari;
138
-
139
-
values=[
140
-
array(newFloat32Array(10)),
141
-
array(newInt32Array(10))
142
-
];
110
+
tape('the function throws an error if provided unequal length vectors (ndarrays)',functiontest(t){
111
+
t.throws(badValue,RangeError,'throws an error');
112
+
t.end();
143
113
144
-
for(i=0;i<values.length;i++){
145
-
t.throws(badValue(values[i]),TypeError,'throws an error when provided '+values[i].toString());
114
+
functionbadValue(){
115
+
varx=array(newFloat64Array(10));
116
+
vary=array(newFloat64Array(100));
117
+
ddot(x,y);
146
118
}
119
+
});
120
+
121
+
tape('the function throws an error if provided unequal length vectors (array-like objects)',functiontest(t){
122
+
t.throws(badValue,RangeError,'throws an error');
147
123
t.end();
148
124
149
-
functionbadValue(value){
150
-
varx=array(newFloat64Array(10));
125
+
functionbadValue(){
126
+
varx=[1,2,3];
127
+
vary=[1,2,3,4,5];
128
+
ddot(x,y);
129
+
}
130
+
});
151
131
152
-
returnfunctionbadValue(){
153
-
ddot(x,value);
132
+
tape('the function throws an error if provided ndarrays which cannot be cast to 1-dimensional ndarrays (ndarrays)',functiontest(t){
133
+
t.throws(badValue,TypeError,'throws an error');
134
+
t.end();
135
+
136
+
functionbadValue(){
137
+
varopts={
138
+
'shape': [5,2]
154
139
};
140
+
varx=array(newFloat64Array(10),opts);
141
+
vary=array(newFloat64Array(10),opts);
142
+
ddot(x,y);
155
143
}
156
144
});
157
145
158
-
tape('the function throws an error if provided vectors which do not have the same length',functiontest(t){
159
-
t.throws(badValue,RangeError,'throws an error');
146
+
tape('the function throws an error if provided array-like objects which cannot be cast to 1-dimensional ndarrays (array-like objects)',functiontest(t){
147
+
t.throws(badValue,TypeError,'throws an error');
160
148
t.end();
161
149
162
150
functionbadValue(){
163
-
varx=array(newFloat64Array(10));
164
-
vary=array(newFloat64Array(100));
151
+
varx=[[1,2],[3,4]];
152
+
vary=[[5,6],[7,8]];
165
153
ddot(x,y);
166
154
}
167
155
});
168
156
169
-
tape('the function calculates the dot product of vectors `x` and `y`',functiontest(t){
157
+
tape('the function calculates the dot product of vectors `x` and `y` (ndarrays)',functiontest(t){
170
158
vardot;
171
159
varx;
172
160
vary;
@@ -183,7 +171,55 @@ tape( 'the function calculates the dot product of vectors `x` and `y`', function
183
171
t.end();
184
172
});
185
173
186
-
tape('if provided empty vectors, the function returns `0`',functiontest(t){
174
+
tape('the function calculates the dot product of vectors `x` and `y` (array-like objects)',functiontest(t){
0 commit comments