Module: ChaosDetector::Utils::TensorUtil
- Defined in:
- lib/chaos_detector/utils/tensor_util.rb
Class Method Summary collapse
-
.normalize_matrix(matrix) ⇒ Object
Return new matrix that is normalized from 0.0(min) to 1.0(max).
Class Method Details
.normalize_matrix(matrix) ⇒ Object
Return new matrix that is normalized from 0.0(min) to 1.0(max)
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/chaos_detector/utils/tensor_util.rb', line 8 def normalize_matrix(matrix) mag = matrix.row_size raise ArgumentError if matrix.column_size != mag lo, hi = matrix.minmax Matrix.build(mag) do |row, col| ChaosDetector::Utils::LerpUtil.delerp(matrix[row, col], min: lo, max: hi) end end |