Skip to content

Commit 644b7d9

Browse files
committed
Added not equal universal function
1 parent 9bb58b2 commit 644b7d9

File tree

6 files changed

+430
-22
lines changed

6 files changed

+430
-22
lines changed

src/ColumnVector.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,38 @@ protected function equalMatrix(Matrix $b) : Matrix
276276
return Matrix::quick($c);
277277
}
278278

279+
/**
280+
* Return the element-wise not equal comparison of this column vector
281+
* and a matrix.
282+
*
283+
* @param \Rubix\Tensor\Matrix $b
284+
* @throws \Rubix\Tensor\Exceptions\DimensionalityMismatchException
285+
* @return \Rubix\Tensor\Matrix
286+
*/
287+
protected function notEqualMatrix(Matrix $b) : Matrix
288+
{
289+
if ($this->n !== $b->m()) {
290+
throw new DimensionalityMismatchException("Vector A requires"
291+
. " $this->n rows but Matrix B has {$b->m()}.");
292+
}
293+
294+
$c = [];
295+
296+
foreach ($b as $i => $row) {
297+
$valueA = $this->a[$i];
298+
299+
$temp = [];
300+
301+
foreach ($row as $valueB) {
302+
$temp[] = $valueA != $valueB ? 1 : 0;
303+
}
304+
305+
$c[] = $temp;
306+
}
307+
308+
return Matrix::quick($c);
309+
}
310+
279311
/**
280312
* Return the element-wise greater than comparison of this column
281313
* vector and a matrix.

0 commit comments

Comments
 (0)