Optimize memory usage in empirical_cross_covariance calculation #214
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves: #213
If X is a large matrix, it might be stored as a float32 array to save memory. However, if Y is of type float64,
the resulting cross-covariance matrix will be float64, potentially doubling the memory usage even if X is float32. To prevent unnecessary memory consumption,
we cast Y to the same data type as X before computing the dot product. This ensures that the output cross-covariance matrix uses memory efficiently while retaining the precision dictated by X's data type.