You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
429 B
22 lines
429 B
4 years ago
|
"use strict"
|
||
|
|
||
|
var ndarray = require("ndarray")
|
||
|
var do_convert = require("./doConvert.js")
|
||
|
|
||
|
module.exports = function convert(arr, result) {
|
||
|
var shape = [], c = arr, sz = 1
|
||
|
while(Array.isArray(c)) {
|
||
|
shape.push(c.length)
|
||
|
sz *= c.length
|
||
|
c = c[0]
|
||
|
}
|
||
|
if(shape.length === 0) {
|
||
|
return ndarray()
|
||
|
}
|
||
|
if(!result) {
|
||
|
result = ndarray(new Float64Array(sz), shape)
|
||
|
}
|
||
|
do_convert(result, arr)
|
||
|
return result
|
||
|
}
|