From 458314aa459133378f26f32da2023d36bdd4e89a Mon Sep 17 00:00:00 2001 From: RandomGamingDev Date: Tue, 6 Feb 2024 19:44:01 -0500 Subject: [PATCH 1/6] added type inference --- src/function/arithmetic/multiply.js | 37 ++++++++++++----------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/src/function/arithmetic/multiply.js b/src/function/arithmetic/multiply.js index daf14bc46d..8a27f7d7ab 100644 --- a/src/function/arithmetic/multiply.js +++ b/src/function/arithmetic/multiply.js @@ -110,11 +110,11 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ // a dense const adata = a._data const asize = a._size - const adt = a._datatype + const adt = a._datatype == undefined ? a.getDataType() : a._datatype; // b dense const bdata = b._data const bsize = b._size - const bdt = b._datatype + const bdt = b._datatype == undefined ? b.getDataType() : b._datatype; // rows & columns const alength = asize[0] const bcolumns = bsize[1] @@ -198,10 +198,10 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ // a dense const adata = a._data const asize = a._size - const adt = a._datatype + const adt = a._datatype == undefined ? a.getDataType() : a._datatype; // b dense const bdata = b._data - const bdt = b._datatype + const bdt = b._datatype == undefined ? b.getDataType() : b._datatype; // rows & columns const arows = asize[0] const acolumns = asize[1] @@ -255,15 +255,15 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ * * @return {Matrix} DenseMatrix (MxC) */ - function _multiplyDenseMatrixDenseMatrix (a, b) { + function _multiplyDenseMatrixDenseMatrix (a, b) { // getDataType() // a dense const adata = a._data const asize = a._size - const adt = a._datatype + const adt = a._datatype == undefined ? a.getDataType() : a._datatype; // b dense const bdata = b._data const bsize = b._size - const bdt = b._datatype + const bdt = b._datatype == undefined ? b.getDataType() : b._datatype; // rows & columns const arows = asize[0] const acolumns = asize[1] @@ -306,13 +306,6 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ c[i][j] = sum } } - - // return matrix - return a.createDenseMatrix({ - data: c, - size: [arows, bcolumns], - datatype: dt - }) } /** @@ -327,13 +320,13 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ // a dense const adata = a._data const asize = a._size - const adt = a._datatype + const adt = a._datatype == undefined ? a.getDataType() : a._datatype; // b sparse const bvalues = b._values const bindex = b._index const bptr = b._ptr const bsize = b._size - const bdt = b._datatype + const bdt = b._datatype == undefined ? b.getDataType() : b._datatype; // validate b matrix if (!bvalues) { throw new Error('Cannot multiply Dense Matrix times Pattern only Matrix') } // rows & columns @@ -437,12 +430,12 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ const avalues = a._values const aindex = a._index const aptr = a._ptr - const adt = a._datatype + const adt = a._datatype == undefined ? a.getDataType() : a._datatype; // validate a matrix if (!avalues) { throw new Error('Cannot multiply Pattern only Matrix times Dense Matrix') } // b dense const bdata = b._data - const bdt = b._datatype + const bdt = b._datatype == undefined ? b.getDataType() : b._datatype; // rows & columns const arows = a._size[0] const brows = b._size[0] @@ -539,12 +532,12 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ const avalues = a._values const aindex = a._index const aptr = a._ptr - const adt = a._datatype + const adt = a._datatype == undefined ? a.getDataType() : a._datatype; // validate a matrix if (!avalues) { throw new Error('Cannot multiply Pattern only Matrix times Dense Matrix') } // b dense const bdata = b._data - const bdt = b._datatype + const bdt = b._datatype == undefined ? b.getDataType() : b._datatype; // rows & columns const arows = a._size[0] const brows = b._size[0] @@ -650,12 +643,12 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ const avalues = a._values const aindex = a._index const aptr = a._ptr - const adt = a._datatype + const adt = a._datatype == undefined ? a.getDataType() : a._datatype; // b sparse const bvalues = b._values const bindex = b._index const bptr = b._ptr - const bdt = b._datatype + const bdt = b._datatype == undefined ? b.getDataType() : b._datatype; // rows & columns const arows = a._size[0] From b5581c5ebd4a84166a5e939c1e32a62c6a0cf320 Mon Sep 17 00:00:00 2001 From: RandomGamingDev Date: Tue, 6 Feb 2024 20:44:29 -0500 Subject: [PATCH 2/6] added back accidentally removed return statement and made it so that the explicitly defined type is returned at the end --- src/function/arithmetic/multiply.js | 86 ++++++++++++++++++++++------- 1 file changed, 66 insertions(+), 20 deletions(-) diff --git a/src/function/arithmetic/multiply.js b/src/function/arithmetic/multiply.js index 8a27f7d7ab..c1fd4b6fc3 100644 --- a/src/function/arithmetic/multiply.js +++ b/src/function/arithmetic/multiply.js @@ -110,11 +110,11 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ // a dense const adata = a._data const asize = a._size - const adt = a._datatype == undefined ? a.getDataType() : a._datatype; + const adt = a._datatype == undefined ? a.getDataType() : a._datatype // b dense const bdata = b._data const bsize = b._size - const bdt = b._datatype == undefined ? b.getDataType() : b._datatype; + const bdt = b._datatype == undefined ? b.getDataType() : b._datatype // rows & columns const alength = asize[0] const bcolumns = bsize[1] @@ -150,12 +150,19 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ c[j] = sum } - // return matrix - return a.createDenseMatrix({ + // matrix to return + const return_matrix = a.createDenseMatrix({ data: c, size: [bcolumns], datatype: dt }) + + // Set the type to undefined if it wasn't defined for a or b + if (adt != a._datatype || bdt != b._datatype) + return_matrix._datatype = undefined + + // return matrix + return return_matrix } /** @@ -198,10 +205,10 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ // a dense const adata = a._data const asize = a._size - const adt = a._datatype == undefined ? a.getDataType() : a._datatype; + const adt = a._datatype == undefined ? a.getDataType() : a._datatype // b dense const bdata = b._data - const bdt = b._datatype == undefined ? b.getDataType() : b._datatype; + const bdt = b._datatype == undefined ? b.getDataType() : b._datatype // rows & columns const arows = asize[0] const acolumns = asize[1] @@ -239,12 +246,19 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ c[i] = sum } - // return matrix - return a.createDenseMatrix({ + // matrix to return + const return_matrix = a.createDenseMatrix({ data: c, size: [arows], datatype: dt }) + + // Set the type to undefined if it wasn't defined for a or b + if (adt != a._datatype || bdt != b._datatype) + return_matrix._datatype = undefined + + // return matrix + return return_matrix } /** @@ -259,11 +273,11 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ // a dense const adata = a._data const asize = a._size - const adt = a._datatype == undefined ? a.getDataType() : a._datatype; + const adt = a._datatype == undefined ? a.getDataType() : a._datatype // b dense const bdata = b._data const bsize = b._size - const bdt = b._datatype == undefined ? b.getDataType() : b._datatype; + const bdt = b._datatype == undefined ? b.getDataType() : b._datatype // rows & columns const arows = asize[0] const acolumns = asize[1] @@ -306,6 +320,20 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ c[i][j] = sum } } + + // matrix to return + const return_matrix = a.createDenseMatrix({ + data: c, + size: [arows, bcolumns], + datatype: dt + }) + + // Set the type to undefined if it wasn't defined for a or b + if (adt != a._datatype || bdt != b._datatype) + return_matrix._datatype = undefined + + // return matrix + return return_matrix } /** @@ -320,13 +348,13 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ // a dense const adata = a._data const asize = a._size - const adt = a._datatype == undefined ? a.getDataType() : a._datatype; + const adt = a._datatype == undefined ? a.getDataType() : a._datatype // b sparse const bvalues = b._values const bindex = b._index const bptr = b._ptr const bsize = b._size - const bdt = b._datatype == undefined ? b.getDataType() : b._datatype; + const bdt = b._datatype == undefined ? b.getDataType() : b._datatype // validate b matrix if (!bvalues) { throw new Error('Cannot multiply Dense Matrix times Pattern only Matrix') } // rows & columns @@ -413,6 +441,10 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ // update ptr cptr[bcolumns] = cindex.length + // Set the type to undefined if it doesn't match + if (adt != a._datatype || bdt != b._datatype) + c._datatype = undefined + // return sparse matrix return c } @@ -430,12 +462,12 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ const avalues = a._values const aindex = a._index const aptr = a._ptr - const adt = a._datatype == undefined ? a.getDataType() : a._datatype; + const adt = a._datatype == undefined ? a.getDataType() : a._datatype // validate a matrix if (!avalues) { throw new Error('Cannot multiply Pattern only Matrix times Dense Matrix') } // b dense const bdata = b._data - const bdt = b._datatype == undefined ? b.getDataType() : b._datatype; + const bdt = b._datatype == undefined ? b.getDataType() : b._datatype // rows & columns const arows = a._size[0] const brows = b._size[0] @@ -509,14 +541,20 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ // update ptr cptr[1] = cindex.length - // return sparse matrix - return a.createSparseMatrix({ + // matrix to return + const return_matrix = a.createSparseMatrix({ values: cvalues, index: cindex, ptr: cptr, size: [arows, 1], datatype: dt }) + + // Set the type to undefined if it wasn't defined for a or b + if (adt != a._datatype || bdt != b._datatype) + return_matrix._datatype = undefined + + return return_matrix } /** @@ -532,12 +570,12 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ const avalues = a._values const aindex = a._index const aptr = a._ptr - const adt = a._datatype == undefined ? a.getDataType() : a._datatype; + const adt = a._datatype == undefined ? a.getDataType() : a._datatype // validate a matrix if (!avalues) { throw new Error('Cannot multiply Pattern only Matrix times Dense Matrix') } // b dense const bdata = b._data - const bdt = b._datatype == undefined ? b.getDataType() : b._datatype; + const bdt = b._datatype == undefined ? b.getDataType() : b._datatype // rows & columns const arows = a._size[0] const brows = b._size[0] @@ -626,6 +664,10 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ // update ptr cptr[bcolumns] = cindex.length + // Set the type to undefined if it wasn't defined for a or b + if (adt != a._datatype || bdt != b._datatype) + c._datatype = undefined + // return sparse matrix return c } @@ -643,12 +685,12 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ const avalues = a._values const aindex = a._index const aptr = a._ptr - const adt = a._datatype == undefined ? a.getDataType() : a._datatype; + const adt = a._datatype == undefined ? a.getDataType() : a._datatype // b sparse const bvalues = b._values const bindex = b._index const bptr = b._ptr - const bdt = b._datatype == undefined ? b.getDataType() : b._datatype; + const bdt = b._datatype == undefined ? b.getDataType() : b._datatype // rows & columns const arows = a._size[0] @@ -749,6 +791,10 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ // update ptr cptr[bcolumns] = cindex.length + // Set the type to undefined if it wasn't defined for a or b + if (adt != a._datatype || bdt != b._datatype) + c._datatype = undefined + // return sparse matrix return c } From ed438be6b5baa3a6aec79e6964025e3105a2bcfb Mon Sep 17 00:00:00 2001 From: RandomGamingDev Date: Tue, 6 Feb 2024 20:49:33 -0500 Subject: [PATCH 3/6] made sure that mixed types are ignored in the process data types check --- src/function/arithmetic/multiply.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/function/arithmetic/multiply.js b/src/function/arithmetic/multiply.js index c1fd4b6fc3..19d70177a6 100644 --- a/src/function/arithmetic/multiply.js +++ b/src/function/arithmetic/multiply.js @@ -127,7 +127,7 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ let mf = multiplyScalar // process data types - if (adt && bdt && adt === bdt && typeof adt === 'string') { + if (adt && bdt && adt === bdt && typeof adt === 'string' && adt !== 'mixed') { // datatype dt = adt // find signatures that matches (dt, dt) @@ -221,7 +221,7 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ let mf = multiplyScalar // process data types - if (adt && bdt && adt === bdt && typeof adt === 'string') { + if (adt && bdt && adt === bdt && typeof adt === 'string' && adt !== 'mixed') { // datatype dt = adt // find signatures that matches (dt, dt) @@ -291,7 +291,7 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ let mf = multiplyScalar // process data types - if (adt && bdt && adt === bdt && typeof adt === 'string') { + if (adt && bdt && adt === bdt && typeof adt === 'string' && adt !== 'mixed' && adt !== 'mixed') { // datatype dt = adt // find signatures that matches (dt, dt) @@ -373,7 +373,7 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ let zero = 0 // process data types - if (adt && bdt && adt === bdt && typeof adt === 'string') { + if (adt && bdt && adt === bdt && typeof adt === 'string' && adt !== 'mixed') { // datatype dt = adt // find signatures that matches (dt, dt) @@ -488,7 +488,7 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ let zero = 0 // process data types - if (adt && bdt && adt === bdt && typeof adt === 'string') { + if (adt && bdt && adt === bdt && typeof adt === 'string' && adt !== 'mixed') { // datatype dt = adt // find signatures that matches (dt, dt) @@ -593,7 +593,7 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ let zero = 0 // process data types - if (adt && bdt && adt === bdt && typeof adt === 'string') { + if (adt && bdt && adt === bdt && typeof adt === 'string' && adt !== 'mixed') { // datatype dt = adt // find signatures that matches (dt, dt) @@ -706,7 +706,7 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ let mf = multiplyScalar // process data types - if (adt && bdt && adt === bdt && typeof adt === 'string') { + if (adt && bdt && adt === bdt && typeof adt === 'string' && adt !== 'mixed') { // datatype dt = adt // find signatures that matches (dt, dt) From ed58386b0f86527b91278c37b9282dabf8608a66 Mon Sep 17 00:00:00 2001 From: RandomGamingDev Date: Tue, 6 Feb 2024 20:58:24 -0500 Subject: [PATCH 4/6] fixed issue with undefined _data for SparseMatrix and linting issues --- src/function/arithmetic/multiply.js | 73 ++++++++++++++++------------- 1 file changed, 40 insertions(+), 33 deletions(-) diff --git a/src/function/arithmetic/multiply.js b/src/function/arithmetic/multiply.js index 19d70177a6..52980af639 100644 --- a/src/function/arithmetic/multiply.js +++ b/src/function/arithmetic/multiply.js @@ -110,11 +110,11 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ // a dense const adata = a._data const asize = a._size - const adt = a._datatype == undefined ? a.getDataType() : a._datatype + const adt = a._datatype === undefined ? a.getDataType() : a._datatype // b dense const bdata = b._data const bsize = b._size - const bdt = b._datatype == undefined ? b.getDataType() : b._datatype + const bdt = b._datatype === undefined ? b.getDataType() : b._datatype // rows & columns const alength = asize[0] const bcolumns = bsize[1] @@ -151,18 +151,19 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ } // matrix to return - const return_matrix = a.createDenseMatrix({ + const returnMatrix = a.createDenseMatrix({ data: c, size: [bcolumns], datatype: dt }) // Set the type to undefined if it wasn't defined for a or b - if (adt != a._datatype || bdt != b._datatype) - return_matrix._datatype = undefined + if (adt !== a._datatype || bdt !== b._datatype) { + returnMatrix._datatype = undefined + } // return matrix - return return_matrix + return returnMatrix } /** @@ -205,10 +206,10 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ // a dense const adata = a._data const asize = a._size - const adt = a._datatype == undefined ? a.getDataType() : a._datatype + const adt = a._datatype === undefined ? a.getDataType() : a._datatype // b dense const bdata = b._data - const bdt = b._datatype == undefined ? b.getDataType() : b._datatype + const bdt = b._datatype === undefined ? b.getDataType() : b._datatype // rows & columns const arows = asize[0] const acolumns = asize[1] @@ -247,18 +248,19 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ } // matrix to return - const return_matrix = a.createDenseMatrix({ + const returnMatrix = a.createDenseMatrix({ data: c, size: [arows], datatype: dt }) // Set the type to undefined if it wasn't defined for a or b - if (adt != a._datatype || bdt != b._datatype) - return_matrix._datatype = undefined + if (adt !== a._datatype || bdt !== b._datatype) { + returnMatrix._datatype = undefined + } // return matrix - return return_matrix + return returnMatrix } /** @@ -273,11 +275,11 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ // a dense const adata = a._data const asize = a._size - const adt = a._datatype == undefined ? a.getDataType() : a._datatype + const adt = a._datatype === undefined ? a.getDataType() : a._datatype // b dense const bdata = b._data const bsize = b._size - const bdt = b._datatype == undefined ? b.getDataType() : b._datatype + const bdt = b._datatype === undefined ? b.getDataType() : b._datatype // rows & columns const arows = asize[0] const acolumns = asize[1] @@ -322,18 +324,19 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ } // matrix to return - const return_matrix = a.createDenseMatrix({ + const returnMatrix = a.createDenseMatrix({ data: c, size: [arows, bcolumns], datatype: dt }) // Set the type to undefined if it wasn't defined for a or b - if (adt != a._datatype || bdt != b._datatype) - return_matrix._datatype = undefined + if (adt !== a._datatype || bdt !== b._datatype) { + returnMatrix._datatype = undefined + } // return matrix - return return_matrix + return returnMatrix } /** @@ -348,13 +351,13 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ // a dense const adata = a._data const asize = a._size - const adt = a._datatype == undefined ? a.getDataType() : a._datatype + const adt = a._datatype === undefined ? a.getDataType() : a._datatype // b sparse const bvalues = b._values const bindex = b._index const bptr = b._ptr const bsize = b._size - const bdt = b._datatype == undefined ? b.getDataType() : b._datatype + const bdt = b._datatype === undefined ? b.getDataType() : b._datatype // validate b matrix if (!bvalues) { throw new Error('Cannot multiply Dense Matrix times Pattern only Matrix') } // rows & columns @@ -442,8 +445,9 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ cptr[bcolumns] = cindex.length // Set the type to undefined if it doesn't match - if (adt != a._datatype || bdt != b._datatype) + if (adt !== a._datatype || bdt !== b._datatype) { c._datatype = undefined + } // return sparse matrix return c @@ -462,12 +466,12 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ const avalues = a._values const aindex = a._index const aptr = a._ptr - const adt = a._datatype == undefined ? a.getDataType() : a._datatype + const adt = a._datatype === undefined ? a.getDataType() : a._datatype // validate a matrix if (!avalues) { throw new Error('Cannot multiply Pattern only Matrix times Dense Matrix') } // b dense const bdata = b._data - const bdt = b._datatype == undefined ? b.getDataType() : b._datatype + const bdt = b._datatype === undefined ? b.getDataType() : b._datatype // rows & columns const arows = a._size[0] const brows = b._size[0] @@ -542,7 +546,7 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ cptr[1] = cindex.length // matrix to return - const return_matrix = a.createSparseMatrix({ + const returnMatrix = a.createSparseMatrix({ values: cvalues, index: cindex, ptr: cptr, @@ -551,10 +555,11 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ }) // Set the type to undefined if it wasn't defined for a or b - if (adt != a._datatype || bdt != b._datatype) - return_matrix._datatype = undefined + if (adt !== a._datatype || bdt !== b._datatype) { + returnMatrix._datatype = undefined + } - return return_matrix + return returnMatrix } /** @@ -570,12 +575,12 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ const avalues = a._values const aindex = a._index const aptr = a._ptr - const adt = a._datatype == undefined ? a.getDataType() : a._datatype + const adt = a._datatype === undefined ? a.getDataType() : a._datatype // validate a matrix if (!avalues) { throw new Error('Cannot multiply Pattern only Matrix times Dense Matrix') } // b dense const bdata = b._data - const bdt = b._datatype == undefined ? b.getDataType() : b._datatype + const bdt = b._datatype === undefined ? b.getDataType() : b._datatype // rows & columns const arows = a._size[0] const brows = b._size[0] @@ -665,8 +670,9 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ cptr[bcolumns] = cindex.length // Set the type to undefined if it wasn't defined for a or b - if (adt != a._datatype || bdt != b._datatype) + if (adt !== a._datatype || bdt !== b._datatype) { c._datatype = undefined + } // return sparse matrix return c @@ -685,12 +691,12 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ const avalues = a._values const aindex = a._index const aptr = a._ptr - const adt = a._datatype == undefined ? a.getDataType() : a._datatype + const adt = a._datatype === undefined && a._data !== undefined ? a.getDataType() : a._datatype // b sparse const bvalues = b._values const bindex = b._index const bptr = b._ptr - const bdt = b._datatype == undefined ? b.getDataType() : b._datatype + const bdt = b._datatype === undefined && b._data !== undefined ? b.getDataType() : b._datatype // rows & columns const arows = a._size[0] @@ -792,8 +798,9 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ cptr[bcolumns] = cindex.length // Set the type to undefined if it wasn't defined for a or b - if (adt != a._datatype || bdt != b._datatype) + if (adt !== a._datatype || bdt !== b._datatype) { c._datatype = undefined + } // return sparse matrix return c From 8369586fadf1d83609f6b85d4f756596b3ebb45a Mon Sep 17 00:00:00 2001 From: RandomGamingDev Date: Sat, 17 Feb 2024 18:45:57 -0500 Subject: [PATCH 5/6] simplified syntax and added type inferencing to src/type/matrix/utils and src/function/matrix/dot.js --- AUTHORS | 1 + src/function/arithmetic/multiply.js | 81 +++++++---------------- src/function/matrix/dot.js | 6 +- src/type/matrix/utils/matAlgo01xDSid.js | 8 +-- src/type/matrix/utils/matAlgo02xDS0.js | 8 +-- src/type/matrix/utils/matAlgo03xDSf.js | 8 +-- src/type/matrix/utils/matAlgo04xSidSid.js | 8 +-- src/type/matrix/utils/matAlgo05xSfSf.js | 8 +-- src/type/matrix/utils/matAlgo06xS0S0.js | 8 +-- src/type/matrix/utils/matAlgo07xSSf.js | 8 +-- src/type/matrix/utils/matAlgo08xS0Sid.js | 8 +-- src/type/matrix/utils/matAlgo09xS0Sf.js | 8 +-- 12 files changed, 65 insertions(+), 95 deletions(-) diff --git a/AUTHORS b/AUTHORS index cd302b33ec..c8ea381be8 100644 --- a/AUTHORS +++ b/AUTHORS @@ -239,5 +239,6 @@ Brooks Smith Alex Edgcomb S.Y. Lee Hudsxn <143907857+Hudsxn@users.noreply.github.com> +RandomGamingDev # Generated by tools/update-authors.js diff --git a/src/function/arithmetic/multiply.js b/src/function/arithmetic/multiply.js index 52980af639..5ed3d4f253 100644 --- a/src/function/arithmetic/multiply.js +++ b/src/function/arithmetic/multiply.js @@ -110,11 +110,11 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ // a dense const adata = a._data const asize = a._size - const adt = a._datatype === undefined ? a.getDataType() : a._datatype + const adt = a._datatype || a.getDataType() // b dense const bdata = b._data const bsize = b._size - const bdt = b._datatype === undefined ? b.getDataType() : b._datatype + const bdt = b._datatype || b.getDataType() // rows & columns const alength = asize[0] const bcolumns = bsize[1] @@ -150,20 +150,12 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ c[j] = sum } - // matrix to return - const returnMatrix = a.createDenseMatrix({ + // return matrix + return a.createDenseMatrix({ data: c, size: [bcolumns], - datatype: dt + datatype: adt === a._datatype && bdt === b._datatype ? dt : undefined }) - - // Set the type to undefined if it wasn't defined for a or b - if (adt !== a._datatype || bdt !== b._datatype) { - returnMatrix._datatype = undefined - } - - // return matrix - return returnMatrix } /** @@ -206,10 +198,10 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ // a dense const adata = a._data const asize = a._size - const adt = a._datatype === undefined ? a.getDataType() : a._datatype + const adt = a._datatype || a.getDataType() // b dense const bdata = b._data - const bdt = b._datatype === undefined ? b.getDataType() : b._datatype + const bdt = b._datatype || b.getDataType() // rows & columns const arows = asize[0] const acolumns = asize[1] @@ -247,20 +239,12 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ c[i] = sum } - // matrix to return - const returnMatrix = a.createDenseMatrix({ + // return matrix + return a.createDenseMatrix({ data: c, size: [arows], - datatype: dt + datatype: adt === a._datatype && bdt === b._datatype ? dt : undefined }) - - // Set the type to undefined if it wasn't defined for a or b - if (adt !== a._datatype || bdt !== b._datatype) { - returnMatrix._datatype = undefined - } - - // return matrix - return returnMatrix } /** @@ -275,11 +259,11 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ // a dense const adata = a._data const asize = a._size - const adt = a._datatype === undefined ? a.getDataType() : a._datatype + const adt = a._datatype || a.getDataType() // b dense const bdata = b._data const bsize = b._size - const bdt = b._datatype === undefined ? b.getDataType() : b._datatype + const bdt = b._datatype || b.getDataType() // rows & columns const arows = asize[0] const acolumns = asize[1] @@ -323,20 +307,12 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ } } - // matrix to return - const returnMatrix = a.createDenseMatrix({ + // return matrix + return a.createDenseMatrix({ data: c, size: [arows, bcolumns], - datatype: dt + datatype: adt === a._datatype && bdt === b._datatype ? dt : undefined }) - - // Set the type to undefined if it wasn't defined for a or b - if (adt !== a._datatype || bdt !== b._datatype) { - returnMatrix._datatype = undefined - } - - // return matrix - return returnMatrix } /** @@ -351,13 +327,13 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ // a dense const adata = a._data const asize = a._size - const adt = a._datatype === undefined ? a.getDataType() : a._datatype + const adt = a._datatype || a.getDataType() // b sparse const bvalues = b._values const bindex = b._index const bptr = b._ptr const bsize = b._size - const bdt = b._datatype === undefined ? b.getDataType() : b._datatype + const bdt = b._datatype || b._data === undefined ? b._datatype : b.getDataType() // validate b matrix if (!bvalues) { throw new Error('Cannot multiply Dense Matrix times Pattern only Matrix') } // rows & columns @@ -466,12 +442,12 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ const avalues = a._values const aindex = a._index const aptr = a._ptr - const adt = a._datatype === undefined ? a.getDataType() : a._datatype + const adt = a._datatype || a._data === undefined ? a._datatype : a.getDataType() // validate a matrix if (!avalues) { throw new Error('Cannot multiply Pattern only Matrix times Dense Matrix') } // b dense const bdata = b._data - const bdt = b._datatype === undefined ? b.getDataType() : b._datatype + const bdt = b._datatype || b.getDataType() // rows & columns const arows = a._size[0] const brows = b._size[0] @@ -546,20 +522,13 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ cptr[1] = cindex.length // matrix to return - const returnMatrix = a.createSparseMatrix({ + return a.createSparseMatrix({ values: cvalues, index: cindex, ptr: cptr, size: [arows, 1], - datatype: dt + datatype: adt === a._datatype && bdt === b._datatype ? dt : undefined }) - - // Set the type to undefined if it wasn't defined for a or b - if (adt !== a._datatype || bdt !== b._datatype) { - returnMatrix._datatype = undefined - } - - return returnMatrix } /** @@ -575,12 +544,12 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ const avalues = a._values const aindex = a._index const aptr = a._ptr - const adt = a._datatype === undefined ? a.getDataType() : a._datatype + const adt = a._datatype || a._data === undefined ? a._datatype : a.getDataType() // validate a matrix if (!avalues) { throw new Error('Cannot multiply Pattern only Matrix times Dense Matrix') } // b dense const bdata = b._data - const bdt = b._datatype === undefined ? b.getDataType() : b._datatype + const bdt = b._datatype || b.getDataType() // rows & columns const arows = a._size[0] const brows = b._size[0] @@ -691,12 +660,12 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ const avalues = a._values const aindex = a._index const aptr = a._ptr - const adt = a._datatype === undefined && a._data !== undefined ? a.getDataType() : a._datatype + const adt = a._datatype || a._data === undefined ? a._datatype : a.getDataType() // b sparse const bvalues = b._values const bindex = b._index const bptr = b._ptr - const bdt = b._datatype === undefined && b._data !== undefined ? b.getDataType() : b._datatype + const bdt = b._datatype || b._data === undefined ? b._datatype : b.getDataType() // rows & columns const arows = a._size[0] diff --git a/src/function/matrix/dot.js b/src/function/matrix/dot.js index bf47bb8b76..3f69ca575a 100644 --- a/src/function/matrix/dot.js +++ b/src/function/matrix/dot.js @@ -64,10 +64,10 @@ export const createDot = /* #__PURE__ */ factory(name, dependencies, ({ typed, a const N = _validateDim(a, b) const adata = isMatrix(a) ? a._data : a - const adt = isMatrix(a) ? a._datatype : undefined + const adt = isMatrix(a) ? a._datatype || a.getDataType() : undefined const bdata = isMatrix(b) ? b._data : b - const bdt = isMatrix(b) ? b._datatype : undefined + const bdt = isMatrix(b) ? b._datatype || b.getDataType() : undefined // are these 2-dimensional column vectors? (as opposed to 1-dimensional vectors) const aIsColumn = _size(a).length === 2 @@ -77,7 +77,7 @@ export const createDot = /* #__PURE__ */ factory(name, dependencies, ({ typed, a let mul = multiplyScalar // process data types - if (adt && bdt && adt === bdt && typeof adt === 'string') { + if (adt && bdt && adt === bdt && typeof adt === 'string' && adt !== 'mixed') { const dt = adt // find signatures that matches (dt, dt) add = typed.find(addScalar, [dt, dt]) diff --git a/src/type/matrix/utils/matAlgo01xDSid.js b/src/type/matrix/utils/matAlgo01xDSid.js index ba413a2b7e..7efb6b72de 100644 --- a/src/type/matrix/utils/matAlgo01xDSid.js +++ b/src/type/matrix/utils/matAlgo01xDSid.js @@ -28,13 +28,13 @@ export const createMatAlgo01xDSid = /* #__PURE__ */ factory(name, dependencies, // dense matrix arrays const adata = denseMatrix._data const asize = denseMatrix._size - const adt = denseMatrix._datatype + const adt = denseMatrix._datatype || denseMatrix.getDataType() // sparse matrix arrays const bvalues = sparseMatrix._values const bindex = sparseMatrix._index const bptr = sparseMatrix._ptr const bsize = sparseMatrix._size - const bdt = sparseMatrix._datatype + const bdt = sparseMatrix._datatype || sparseMatrix._data === undefined ? sparseMatrix._datatype : sparseMatrix.getDataType() // validate dimensions if (asize.length !== bsize.length) { throw new DimensionError(asize.length, bsize.length) } @@ -50,7 +50,7 @@ export const createMatAlgo01xDSid = /* #__PURE__ */ factory(name, dependencies, const columns = asize[1] // process data types - const dt = typeof adt === 'string' && adt === bdt ? adt : undefined + const dt = typeof adt === 'string' && adt !== 'mixed' && adt === bdt ? adt : undefined // callback function const cf = dt ? typed.find(callback, [dt, dt]) : callback @@ -97,7 +97,7 @@ export const createMatAlgo01xDSid = /* #__PURE__ */ factory(name, dependencies, return denseMatrix.createDenseMatrix({ data: cdata, size: [rows, columns], - datatype: dt + datatype: adt === denseMatrix._datatype && bdt === sparseMatrix._datatype ? dt : undefined }) } }) diff --git a/src/type/matrix/utils/matAlgo02xDS0.js b/src/type/matrix/utils/matAlgo02xDS0.js index f11dad48a7..0c3d5b8f6a 100644 --- a/src/type/matrix/utils/matAlgo02xDS0.js +++ b/src/type/matrix/utils/matAlgo02xDS0.js @@ -28,13 +28,13 @@ export const createMatAlgo02xDS0 = /* #__PURE__ */ factory(name, dependencies, ( // dense matrix arrays const adata = denseMatrix._data const asize = denseMatrix._size - const adt = denseMatrix._datatype + const adt = denseMatrix._datatype || denseMatrix.getDataType() // sparse matrix arrays const bvalues = sparseMatrix._values const bindex = sparseMatrix._index const bptr = sparseMatrix._ptr const bsize = sparseMatrix._size - const bdt = sparseMatrix._datatype + const bdt = sparseMatrix._datatype || sparseMatrix._data === undefined ? sparseMatrix._datatype : sparseMatrix.getDataType() // validate dimensions if (asize.length !== bsize.length) { throw new DimensionError(asize.length, bsize.length) } @@ -59,7 +59,7 @@ export const createMatAlgo02xDS0 = /* #__PURE__ */ factory(name, dependencies, ( let cf = callback // process data types - if (typeof adt === 'string' && adt === bdt) { + if (typeof adt === 'string' && adt === bdt && adt !== 'mixed') { // datatype dt = adt // find signature that matches (dt, dt) @@ -102,7 +102,7 @@ export const createMatAlgo02xDS0 = /* #__PURE__ */ factory(name, dependencies, ( index: cindex, ptr: cptr, size: [rows, columns], - datatype: dt + datatype: adt === denseMatrix._datatype && bdt === sparseMatrix._datatype ? dt : undefined }) } }) diff --git a/src/type/matrix/utils/matAlgo03xDSf.js b/src/type/matrix/utils/matAlgo03xDSf.js index c3d4965270..bed698bf59 100644 --- a/src/type/matrix/utils/matAlgo03xDSf.js +++ b/src/type/matrix/utils/matAlgo03xDSf.js @@ -28,13 +28,13 @@ export const createMatAlgo03xDSf = /* #__PURE__ */ factory(name, dependencies, ( // dense matrix arrays const adata = denseMatrix._data const asize = denseMatrix._size - const adt = denseMatrix._datatype + const adt = denseMatrix._datatype || denseMatrix.getDataType() // sparse matrix arrays const bvalues = sparseMatrix._values const bindex = sparseMatrix._index const bptr = sparseMatrix._ptr const bsize = sparseMatrix._size - const bdt = sparseMatrix._datatype + const bdt = sparseMatrix._datatype || sparseMatrix._data === undefined ? sparseMatrix._datatype : sparseMatrix.getDataType() // validate dimensions if (asize.length !== bsize.length) { throw new DimensionError(asize.length, bsize.length) } @@ -57,7 +57,7 @@ export const createMatAlgo03xDSf = /* #__PURE__ */ factory(name, dependencies, ( let cf = callback // process data types - if (typeof adt === 'string' && adt === bdt) { + if (typeof adt === 'string' && adt === bdt && adt !== 'mixed') { // datatype dt = adt // convert 0 to the same datatype @@ -109,7 +109,7 @@ export const createMatAlgo03xDSf = /* #__PURE__ */ factory(name, dependencies, ( return denseMatrix.createDenseMatrix({ data: cdata, size: [rows, columns], - datatype: dt + datatype: adt === denseMatrix._datatype && bdt === sparseMatrix._datatype ? dt : undefined }) } }) diff --git a/src/type/matrix/utils/matAlgo04xSidSid.js b/src/type/matrix/utils/matAlgo04xSidSid.js index a98e4ba91a..2d377f2e88 100644 --- a/src/type/matrix/utils/matAlgo04xSidSid.js +++ b/src/type/matrix/utils/matAlgo04xSidSid.js @@ -29,13 +29,13 @@ export const createMatAlgo04xSidSid = /* #__PURE__ */ factory(name, dependencies const aindex = a._index const aptr = a._ptr const asize = a._size - const adt = a._datatype + const adt = a._datatype || a._data === undefined ? a._datatype : a.getDataType() // sparse matrix arrays const bvalues = b._values const bindex = b._index const bptr = b._ptr const bsize = b._size - const bdt = b._datatype + const bdt = b._datatype || b._data === undefined ? b._datatype : b.getDataType() // validate dimensions if (asize.length !== bsize.length) { throw new DimensionError(asize.length, bsize.length) } @@ -57,7 +57,7 @@ export const createMatAlgo04xSidSid = /* #__PURE__ */ factory(name, dependencies let cf = callback // process data types - if (typeof adt === 'string' && adt === bdt) { + if (typeof adt === 'string' && adt === bdt && adt !== 'mixed') { // datatype dt = adt // find signature that matches (dt, dt) @@ -163,7 +163,7 @@ export const createMatAlgo04xSidSid = /* #__PURE__ */ factory(name, dependencies index: cindex, ptr: cptr, size: [rows, columns], - datatype: dt + datatype: adt === a._datatype && bdt === b._datatype ? dt : undefined }) } }) diff --git a/src/type/matrix/utils/matAlgo05xSfSf.js b/src/type/matrix/utils/matAlgo05xSfSf.js index 26af3300fc..f504de9de1 100644 --- a/src/type/matrix/utils/matAlgo05xSfSf.js +++ b/src/type/matrix/utils/matAlgo05xSfSf.js @@ -29,13 +29,13 @@ export const createMatAlgo05xSfSf = /* #__PURE__ */ factory(name, dependencies, const aindex = a._index const aptr = a._ptr const asize = a._size - const adt = a._datatype + const adt = a._datatype || a._data === undefined ? a._datatype : a.getDataType() // sparse matrix arrays const bvalues = b._values const bindex = b._index const bptr = b._ptr const bsize = b._size - const bdt = b._datatype + const bdt = b._datatype || b._data === undefined ? b._datatype : b.getDataType() // validate dimensions if (asize.length !== bsize.length) { throw new DimensionError(asize.length, bsize.length) } @@ -57,7 +57,7 @@ export const createMatAlgo05xSfSf = /* #__PURE__ */ factory(name, dependencies, let cf = callback // process data types - if (typeof adt === 'string' && adt === bdt) { + if (typeof adt === 'string' && adt === bdt && adt !== 'mixed') { // datatype dt = adt // find signature that matches (dt, dt) @@ -155,7 +155,7 @@ export const createMatAlgo05xSfSf = /* #__PURE__ */ factory(name, dependencies, index: cindex, ptr: cptr, size: [rows, columns], - datatype: dt + datatype: adt === a._datatype && bdt === b._datatype ? dt : undefined }) } }) diff --git a/src/type/matrix/utils/matAlgo06xS0S0.js b/src/type/matrix/utils/matAlgo06xS0S0.js index c07613e9fc..c2497e4ed0 100644 --- a/src/type/matrix/utils/matAlgo06xS0S0.js +++ b/src/type/matrix/utils/matAlgo06xS0S0.js @@ -28,11 +28,11 @@ export const createMatAlgo06xS0S0 = /* #__PURE__ */ factory(name, dependencies, // sparse matrix arrays const avalues = a._values const asize = a._size - const adt = a._datatype + const adt = a._datatype || a._data === undefined ? a._datatype : a.getDataType() // sparse matrix arrays const bvalues = b._values const bsize = b._size - const bdt = b._datatype + const bdt = b._datatype || b._data === undefined ? b._datatype : b.getDataType() // validate dimensions if (asize.length !== bsize.length) { throw new DimensionError(asize.length, bsize.length) } @@ -54,7 +54,7 @@ export const createMatAlgo06xS0S0 = /* #__PURE__ */ factory(name, dependencies, let cf = callback // process data types - if (typeof adt === 'string' && adt === bdt) { + if (typeof adt === 'string' && adt === bdt && adt !== 'mixed') { // datatype dt = adt // find signature that matches (dt, dt) @@ -141,7 +141,7 @@ export const createMatAlgo06xS0S0 = /* #__PURE__ */ factory(name, dependencies, index: cindex, ptr: cptr, size: [rows, columns], - datatype: dt + datatype: adt === a._datatype && bdt === b._datatype ? dt : undefined }) } }) diff --git a/src/type/matrix/utils/matAlgo07xSSf.js b/src/type/matrix/utils/matAlgo07xSSf.js index a2e588f6eb..2e42cb0c03 100644 --- a/src/type/matrix/utils/matAlgo07xSSf.js +++ b/src/type/matrix/utils/matAlgo07xSSf.js @@ -22,10 +22,10 @@ export const createMatAlgo07xSSf = /* #__PURE__ */ factory(name, dependencies, ( return function matAlgo07xSSf (a, b, callback) { // sparse matrix arrays const asize = a._size - const adt = a._datatype + const adt = a._datatype || a._data === undefined ? a._datatype : a.getDataType() // sparse matrix arrays const bsize = b._size - const bdt = b._datatype + const bdt = b._datatype || b._data === undefined ? b._datatype : b.getDataType() // validate dimensions if (asize.length !== bsize.length) { throw new DimensionError(asize.length, bsize.length) } @@ -45,7 +45,7 @@ export const createMatAlgo07xSSf = /* #__PURE__ */ factory(name, dependencies, ( let cf = callback // process data types - if (typeof adt === 'string' && adt === bdt) { + if (typeof adt === 'string' && adt === bdt && adt !== 'mixed') { // datatype dt = adt // convert 0 to the same datatype @@ -91,7 +91,7 @@ export const createMatAlgo07xSSf = /* #__PURE__ */ factory(name, dependencies, ( return new DenseMatrix({ data: cdata, size: [rows, columns], - datatype: dt + datatype: adt === a._datatype && bdt === b._datatype ? dt : undefined }) } diff --git a/src/type/matrix/utils/matAlgo08xS0Sid.js b/src/type/matrix/utils/matAlgo08xS0Sid.js index b42f9bd185..210752e8c5 100644 --- a/src/type/matrix/utils/matAlgo08xS0Sid.js +++ b/src/type/matrix/utils/matAlgo08xS0Sid.js @@ -29,13 +29,13 @@ export const createMatAlgo08xS0Sid = /* #__PURE__ */ factory(name, dependencies, const aindex = a._index const aptr = a._ptr const asize = a._size - const adt = a._datatype + const adt = a._datatype || a._data === undefined ? a._datatype : a.getDataType() // sparse matrix arrays const bvalues = b._values const bindex = b._index const bptr = b._ptr const bsize = b._size - const bdt = b._datatype + const bdt = b._datatype || b._data === undefined ? b._datatype : b.getDataType() // validate dimensions if (asize.length !== bsize.length) { throw new DimensionError(asize.length, bsize.length) } @@ -60,7 +60,7 @@ export const createMatAlgo08xS0Sid = /* #__PURE__ */ factory(name, dependencies, let cf = callback // process data types - if (typeof adt === 'string' && adt === bdt) { + if (typeof adt === 'string' && adt === bdt && adt !== 'mixed') { // datatype dt = adt // find signature that matches (dt, dt) @@ -140,7 +140,7 @@ export const createMatAlgo08xS0Sid = /* #__PURE__ */ factory(name, dependencies, index: cindex, ptr: cptr, size: [rows, columns], - datatype: dt + datatype: adt === a._datatype && bdt === b._datatype ? dt : undefined }) } }) diff --git a/src/type/matrix/utils/matAlgo09xS0Sf.js b/src/type/matrix/utils/matAlgo09xS0Sf.js index 1cee1af7ed..643bc32de0 100644 --- a/src/type/matrix/utils/matAlgo09xS0Sf.js +++ b/src/type/matrix/utils/matAlgo09xS0Sf.js @@ -29,13 +29,13 @@ export const createMatAlgo09xS0Sf = /* #__PURE__ */ factory(name, dependencies, const aindex = a._index const aptr = a._ptr const asize = a._size - const adt = a._datatype + const adt = a._datatype || a._data === undefined ? a._datatype : a.getDataType() // sparse matrix arrays const bvalues = b._values const bindex = b._index const bptr = b._ptr const bsize = b._size - const bdt = b._datatype + const bdt = b._datatype || b._data === undefined ? b._datatype : b.getDataType() // validate dimensions if (asize.length !== bsize.length) { throw new DimensionError(asize.length, bsize.length) } @@ -57,7 +57,7 @@ export const createMatAlgo09xS0Sf = /* #__PURE__ */ factory(name, dependencies, let cf = callback // process data types - if (typeof adt === 'string' && adt === bdt) { + if (typeof adt === 'string' && adt === bdt && adt !== 'mixed') { // datatype dt = adt // find signature that matches (dt, dt) @@ -130,7 +130,7 @@ export const createMatAlgo09xS0Sf = /* #__PURE__ */ factory(name, dependencies, index: cindex, ptr: cptr, size: [rows, columns], - datatype: dt + datatype: adt === a._datatype && bdt === b._datatype ? dt : undefined }) } }) From 44d9dd4529b3d0ac0f162262b4e4aa053c5f20d0 Mon Sep 17 00:00:00 2001 From: RandomGamingDev Date: Wed, 21 Feb 2024 14:33:51 -0500 Subject: [PATCH 6/6] shortened the final part of the type inferencing and moved it to matrix creation in multiply --- src/function/arithmetic/multiply.js | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/src/function/arithmetic/multiply.js b/src/function/arithmetic/multiply.js index 5ed3d4f253..19bd3b7eef 100644 --- a/src/function/arithmetic/multiply.js +++ b/src/function/arithmetic/multiply.js @@ -373,7 +373,7 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ index: cindex, ptr: cptr, size: [arows, bcolumns], - datatype: dt + datatype: adt === a._datatype && bdt === b._datatype ? dt : undefined }) // loop b columns @@ -420,11 +420,6 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ // update ptr cptr[bcolumns] = cindex.length - // Set the type to undefined if it doesn't match - if (adt !== a._datatype || bdt !== b._datatype) { - c._datatype = undefined - } - // return sparse matrix return c } @@ -588,7 +583,7 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ index: cindex, ptr: cptr, size: [arows, bcolumns], - datatype: dt + datatype: adt === a._datatype && bdt === b._datatype ? dt : undefined }) // workspace @@ -638,11 +633,6 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ // update ptr cptr[bcolumns] = cindex.length - // Set the type to undefined if it wasn't defined for a or b - if (adt !== a._datatype || bdt !== b._datatype) { - c._datatype = undefined - } - // return sparse matrix return c } @@ -699,7 +689,7 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ index: cindex, ptr: cptr, size: [arows, bcolumns], - datatype: dt + datatype: adt === a._datatype && bdt === b._datatype ? dt : undefined }) // workspace @@ -766,11 +756,6 @@ export const createMultiply = /* #__PURE__ */ factory(name, dependencies, ({ typ // update ptr cptr[bcolumns] = cindex.length - // Set the type to undefined if it wasn't defined for a or b - if (adt !== a._datatype || bdt !== b._datatype) { - c._datatype = undefined - } - // return sparse matrix return c }