MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / equals

Function equals

src/compute-engine/tensor/tensors.ts:845–863  ·  view source on GitHub ↗
(rhs: AbstractTensor<DT>)

Source from the content-addressed store, hash-verified

843 // deferred validation (§D6.2) — a `list`-typed operand may evaluate to a
844 // boolean tensor; the handler then declines (inert) instead of throwing.
845 if (this.dtype === 'bool') return undefined;
846 if (this.rank !== 2) return undefined;
847 const [m, n] = this.shape;
848 if (m !== n) return undefined;
849 if (n === 1)
850 return makeTensor(this.ce, {
851 dtype: this.dtype,
852 shape: [1, 1],
853 data: [this.field.one],
854 });
855 const neg = this.field.neg.bind(this.field);
856 const data: DataTypeMap[DT][] = [];
857 for (let i = 1; i <= n; i++)
858 for (let j = 1; j <= n; j++) {
859 const minor = this.minor(j, i);
860 if (minor === undefined) return undefined;
861 data.push((i + j) % 2 === 0 ? minor : neg(minor));
862 }
863 return makeTensor(this.ce, { dtype: this.dtype, shape: [n, n], data });
864 }
865
866 // The determinant of the matrix obtained by deleting row i and column j from this matrix. https://en.wikipedia.org/wiki/Minor_(linear_algebra)

Callers

nothing calls this directly

Calls 2

eqFunction · 0.85
bindMethod · 0.65

Tested by

no test coverage detected