Class: Matrix Private
- Defined in:
- lib/musa-dsl/matrix/matrix.rb,
lib/musa-dsl/matrix/matrix.rb,
lib/musa-dsl/matrix/matrix.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
POTENTIAL LOGIC INCONSISTENCY: Review the direction logic in backward and forward scans.
- Line 300 comment: "Scan backward... while time is non-decreasing"
- Line 306 code:
while i >= 0 && array[i][time_dimension] >= xx - Line 316 comment: "Scan forward... while time is non-decreasing"
- Line 322 code:
while i < array.size && array[i][time_dimension] >= xxBoth scans use>= xx, which seems contradictory. When scanning backward (decreasing indices), for "non-decreasing time" we might expect<= xx(times getting smaller or equal as we go back in indices). Currently both directions use the same comparison operator. IMPLEMENT TESTS to verify expected behavior with various input patterns and confirm whether this is intentional or a bug. Test cases should include: - Forward-only monotonic sequences
- Backward-only monotonic sequences
- Mixed direction sequences
- The example documented above
Decomposes an array of points into directional segments based on a time dimension.
This private method analyzes the array to find monotonic (non-decreasing) sequences in the specified time dimension. It scans bidirectionally from each point to discover maximal segments where time progresses consistently.
The algorithm:
- Groups points by their time values
- Iterates through time values in sorted order
- For each unprocessed index, scans backward and forward
- Collects points while time is non-decreasing
- Returns segments with 2+ points
Instance Method Summary collapse
-
#_rows ⇒ Array<Array>
private
Provides direct access to the internal rows array of the matrix.
-
#decompose(array, time_dimension) ⇒ Array<Array<Array>>
private
Decomposes an array of points into directional segments based on a time dimension.
-
#to_p(time_dimension: , keep_time: nil) ⇒ Array<Musa::Datasets::P>
Converts a matrix to one or more P (point sequence) representations.
Instance Method Details
#_rows ⇒ Array<Array>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method is added to Matrix via refinement. Requires using Musa::Extension::Matrix.
This method accesses Ruby's Matrix internals and should be used with caution.
Provides direct access to the internal rows array of the matrix.
This is a utility method used primarily by Array#condensed_matrices to manipulate matrix rows when merging matrices with shared boundaries.
269 |
# File 'lib/musa-dsl/matrix/matrix.rb', line 269 class ::Matrix; end |
#decompose(array, time_dimension) ⇒ Array<Array<Array>>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
POTENTIAL LOGIC INCONSISTENCY: Review the direction logic in backward and forward scans.
- Line 300 comment: "Scan backward... while time is non-decreasing"
- Line 306 code:
while i >= 0 && array[i][time_dimension] >= xx - Line 316 comment: "Scan forward... while time is non-decreasing"
- Line 322 code:
while i < array.size && array[i][time_dimension] >= xxBoth scans use>= xx, which seems contradictory. When scanning backward (decreasing indices), for "non-decreasing time" we might expect<= xx(times getting smaller or equal as we go back in indices). Currently both directions use the same comparison operator. IMPLEMENT TESTS to verify expected behavior with various input patterns and confirm whether this is intentional or a bug. Test cases should include: - Forward-only monotonic sequences
- Backward-only monotonic sequences
- Mixed direction sequences
- The example documented above
Decomposes an array of points into directional segments based on a time dimension.
This private method analyzes the array to find monotonic (non-decreasing) sequences in the specified time dimension. It scans bidirectionally from each point to discover maximal segments where time progresses consistently.
The algorithm:
- Groups points by their time values
- Iterates through time values in sorted order
- For each unprocessed index, scans backward and forward
- Collects points while time is non-decreasing
- Returns segments with 2+ points
316 |
# File 'lib/musa-dsl/matrix/matrix.rb', line 316 class ::Matrix; end |
#to_p(time_dimension: , keep_time: nil) ⇒ Array<Musa::Datasets::P>
This method is added to Matrix via refinement. Requires using Musa::Extension::Matrix.
Converts a matrix to one or more P (point sequence) representations.
This method decomposes the matrix into directional segments based on the time dimension, then converts each segment into a P sequence format suitable for representing musical gestures in Musa DSL.
A P sequence is an array extended with the P module, containing alternating value arrays (extended with V module) and numeric time deltas: [value1, delta1, value2, delta2, ..., valueN].extend(P) where each value is an array extended with V module.
The decomposition process identifies monotonic segments in the time dimension, handling cases where the temporal ordering might have reversals or non-linearities.
255 |
# File 'lib/musa-dsl/matrix/matrix.rb', line 255 class ::Matrix; end |