* Apply a callback function to each element of the tensor in place. * @param {Function} callback - The function to apply to each element. It should take three arguments: * the current element, its index, and the tensor's data array. * @returns {Tensor} Ret
(callback)
| 239 | * @returns {Tensor} Returns `this`. |
| 240 | */ |
| 241 | map_(callback) { |
| 242 | const this_data = this.data; |
| 243 | for (let i = 0; i < this_data.length; ++i) { |
| 244 | this_data[i] = callback(this_data[i], i, this_data); |
| 245 | } |
| 246 | return this; |
| 247 | } |
| 248 | |
| 249 | /** |
| 250 | * Return a new Tensor with every element multiplied by a constant. |