Skip to content

Conversation

@shivasankarka
Copy link
Collaborator

@shivasankarka shivasankarka commented Oct 21, 2025

Pull Request Overview (From Copilot)

This PR enhances ComplexNDArray functionality by adding comparison operators, trait methods, statistical/reduction methods, and array manipulation capabilities. It also introduces temporary Int conversions for strides/shape operations and implements SIMD load/store methods for vectorized calculations.

Key Changes

  • Added trait implementations (ImplicitlyCopyable, Movable) and conversion methods (bool, int, float) for ComplexNDArray
  • Implemented magnitude-based comparison operators (lt, le, gt, ge) for complex arrays
  • Added statistical methods (all, any, sum, prod, mean, max, min, argmax, argmin, cumsum, cumprod) and array manipulation methods (flatten, fill, row, col, clip, round, T, diagonal, trace, tolist, resize)
  • Changed internal buffer types from UnsafePointer[Int] to UnsafePointer[Scalar[DType.int]] in NDArrayShape, NDArrayStrides, and Item structs
  • Added SIMD load/store methods (load, store, unsafe_load, unsafe_store) for Item, Shape, and Strides
Show a summary per file
File Description
numojo/routines/indexing.mojo Added Int conversions for stride operations in compress function
numojo/routines/creation.mojo Removed duplicate import statements
numojo/core/ndstrides.mojo Changed buffer type to Scalar[DType.int], updated setitem validation, added SIMD load/store methods
numojo/core/ndshape.mojo Changed buffer type to Scalar[DType.int], updated setitem validation, added SIMD load/store methods, modified size_of_array calculation
numojo/core/ndarray.mojo Added Int conversions for stride/shape buffer accesses throughout
numojo/core/item.mojo Changed buffer type to Scalar[DType.int], removed Item.init(idx, shape) constructor and offset() method, added SIMD load/store methods
numojo/core/complex/complex_simd.mojo Added ImplicitlyCopyable and Movable traits to ComplexSIMD
numojo/core/complex/complex_ndarray.mojo Added comparison operators, conversion methods, power operations, statistical methods, and array manipulation methods; added Int conversions for stride operations

@shivasankarka shivasankarka changed the base branch from main to pre-0.8 October 21, 2025 10:21
@shivasankarka shivasankarka marked this pull request as draft October 21, 2025 10:21
@shivasankarka shivasankarka changed the title [core][NDArray] Add origin tracking to NDArray to enable creation of Views [core][ComplexNDArray] Improve methods of ComplexNDArray Oct 21, 2025
@shivasankarka shivasankarka changed the title [core][ComplexNDArray] Improve methods of ComplexNDArray [core][ComplexNDArray] Improve ComplexNDArray methods Oct 21, 2025
@shivasankarka shivasankarka marked this pull request as ready for review October 21, 2025 15:32
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances ComplexNDArray functionality by adding comparison operators, trait methods, statistical/reduction methods, and array manipulation capabilities. It also introduces temporary Int conversions for strides/shape operations and implements SIMD load/store methods for vectorized calculations.

Key Changes

  • Added trait implementations (ImplicitlyCopyable, Movable) and conversion methods (bool, int, float) for ComplexNDArray
  • Implemented magnitude-based comparison operators (lt, le, gt, ge) for complex arrays
  • Added statistical methods (all, any, sum, prod, mean, max, min, argmax, argmin, cumsum, cumprod) and array manipulation methods (flatten, fill, row, col, clip, round, T, diagonal, trace, tolist, resize)
  • Changed internal buffer types from UnsafePointer[Int] to UnsafePointer[Scalar[DType.int]] in NDArrayShape, NDArrayStrides, and Item structs
  • Added SIMD load/store methods (load, store, unsafe_load, unsafe_store) for Item, Shape, and Strides

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
numojo/routines/indexing.mojo Added Int conversions for stride operations in compress function
numojo/routines/creation.mojo Removed duplicate import statements
numojo/core/ndstrides.mojo Changed buffer type to Scalar[DType.int], updated setitem validation, added SIMD load/store methods
numojo/core/ndshape.mojo Changed buffer type to Scalar[DType.int], updated setitem validation, added SIMD load/store methods, modified size_of_array calculation
numojo/core/ndarray.mojo Added Int conversions for stride/shape buffer accesses throughout
numojo/core/item.mojo Changed buffer type to Scalar[DType.int], removed Item.init(idx, shape) constructor and offset() method, added SIMD load/store methods
numojo/core/complex/complex_simd.mojo Added ImplicitlyCopyable and Movable traits to ComplexSIMD
numojo/core/complex/complex_ndarray.mojo Added comparison operators, conversion methods, power operations, statistical methods, and array manipulation methods; added Int conversions for stride operations

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Collaborator

@forfudan forfudan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the changes!

I just noticed that Mojo renamed DType.index as DType.int now. It is a good though. I think in future maybe Int can be an alias for DType.int instead of being another independent type.

Copy link
Collaborator

@forfudan forfudan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the changes!

I just noticed that Mojo renamed DType.index as DType.int now. It is a good though. I think in future maybe Int can be an alias for DType.int instead of being another independent type.

@shivasankarka
Copy link
Collaborator Author

Thank you for the changes!

I just noticed that Mojo renamed DType.index as DType.int now. It is a good though. I think in future maybe Int can be an alias for DType.int instead of being another independent type.

Yes! Mojo is moving toward a single DType.int and make Int as an alias for SIMD[DType.int]. I think it's good and helps us remove a lot of the conversions going on everywhere. Also, we can vectorize a lot of index computations explicitly now!

@shivasankarka shivasankarka merged commit ba0249e into Mojo-Numerics-and-Algorithms-group:pre-0.8 Oct 24, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants