Skip to content

Commit 4366c7b

Browse files
authored
Merge pull request #45 from Mojo-Numerics-and-Algorithms-group/ndarray
[lib+doc+test] Implement NDArray, basic functions and routines
2 parents ea053f0 + 8186939 commit 4366c7b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+7848
-3564
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Build directory
2+
/build
3+
/dist
4+
/local

CONTRIBUTING.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ Thank you for your interest in contributing to NuMojo! We appreciate your effort
55
## Style Guide
66

77
Please follow the Mojo standard library style guide for all contributions. Consistency in code style helps maintain readability and ease of collaboration. Key points include:
8+
89
- Use clear, descriptive names for variables and functions.
910
- Write concise, well-documented code.
1011
- Adhere to formatting conventions for indentation, spacing, and line breaks.
1112

1213
## Pull Requests
1314

1415
When submitting pull requests:
16+
1517
- Ensure they are small but complete. A pull request should introduce at least a minimally viable version of the feature you are adding.
1618
- Include tests for your contributions where applicable.
1719
- Provide a clear and concise description of what your pull request accomplishes.
@@ -23,31 +25,39 @@ If you have an idea or want to work on something, go ahead and do it! You don’
2325
## Directory Structure
2426

2527
Organize your additions into the appropriate submodule or file, if one does not exist feel free to make it and we can figure out where it goes during the pull request checks. This helps keep the project structured and maintainable. For example:
28+
2629
- If you’re adding a statistics function, place it in the `stats` submodule.
27-
- If a stats module does not yet exist put the code in a directory called stats in a file with a name that describes the sub disipline of statistics the code enables, along with a `__init__.mojo`
28-
- For a kernel density estimation function, add it to the `kde.mojo` file within the `stats` directory.
30+
- If a stats module does not yet exist put the code in a directory called stats in a file with a name that describes the sub disipline of statistics the code enables, along with a `__init__.mojo`
31+
- For a kernel density estimation function, add it to the `kde.mojo` file within the `stats` directory.
2932

3033
Following this structure ensures that similar functionalities are grouped together, making the codebase easier to navigate.
3134

3235
## Contribution Process
3336

3437
1. **Fork the Repository**: Create a personal fork of the repository on GitHub.
3538
2. **Clone Your Fork**: Clone your forked repository to your local machine.
39+
3640
```sh
3741
git clone https://github.com/your-username/numojo.git
3842
```
43+
3944
3. **Create a Branch**: Create a new branch for your feature or bugfix.
45+
4046
```sh
4147
git checkout -b feature-name
4248
```
49+
4350
4. **Make Your Changes**: Implement your changes in your branch.
4451
5. **Commit Your Changes**: Commit your changes with a clear and descriptive commit message.
52+
4553
```sh
4654
git commit -m "Add feature XYZ"
4755
```
56+
4857
6. **Push Your Changes**: Push your branch to your fork on GitHub.
58+
4959
```sh
5060
git push origin feature-name
5161
```
52-
7. **Submit a Pull Request**: Open a pull request to the `main` branch of the original repository.
5362

63+
7. **Submit a Pull Request**: Open a pull request to the `main` branch of the original repository.

README.MD

Lines changed: 81 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,119 @@
1-
<br/>
2-
<p align="center">
3-
<!-- If we add a logo in future -->
4-
<!-- <a href="">
5-
<img src="" alt="Logo" width="200" height="200">
6-
</a> -->
7-
8-
<h1 align="center">NuMojo</h1>
1+
<a name="readme-top"></a>
2+
<!-- add these later -->
3+
<!-- [![MIT License][license-shield]][] -->
4+
5+
<div align="center">
6+
<a href="">
7+
<img src="./assets/numojo_logo.png" alt="Logo" width="350" height="350">
8+
</a>
9+
10+
<h1 align="center" style="font-size: 3em; color: white; font-family: 'Avenir'; text-shadow: 1px 1px orange;">NuMojo</h1>
11+
912
<p align="center">
10-
NuMojo is a library for numerical computing in Mojo 🔥 similar to numpy in Python.
13+
NuMojo is a library for numerical computing in Mojo 🔥 similar to NumPy, SciPy in Python.
14+
<br />
15+
<!-- when we create docs -->
16+
<a href="https://github.com/Mojo-Numerics-and-Algorithms-group/NuMojo-Examples-and-Benchmarks/blob/main/docs/README.md"><strong>Explore the docs» </strong></a>
17+
<br />
18+
<!-- <br /> -->
19+
<!-- <a href="">View Demo</a>
20+
·
21+
<a href="">Report Bug</a>
22+
·
23+
<a href="">Request Feature</a> -->
1124
</p>
12-
</p>
25+
</div>
26+
27+
<details>
28+
<summary>Table of Contents</summary>
29+
<ol>
30+
<li>
31+
<a href="#about-the-project">About The Project</a>
32+
<ul>
33+
<li><a href="#what-numojo-is"> What NuMojo is </a></li>
34+
<li><a href="#what-numojo-is-not">What NuMojo is not</a></li>
35+
</ul>
36+
</li>
37+
<a href="#goals-roadmap">Goals/Roadmap</a>
38+
<ul>
39+
<li><a href="#long-term-goals">Long term goals</a></li>
40+
</ul>
41+
<li><a href="#usage">Usage</a></li>
42+
<li><a href="#how-to-install">How to install</a></li>
43+
<li><a href="#contributing">Contributing</a></li>
44+
<li><a href="#warnings">Warnings</a></li>
45+
<li><a href="#license">License</a></li>
46+
<li><a href="#acknowledgments">Acknowledgments</a></li>
47+
</ol>
48+
</details>
1349

1450
## About the project
51+
52+
### What NuMojo is
53+
1554
NuMojo intends to capture a wide swath of numerics capability present in the Python packages NumPy, SciPy and Scikit.
1655

56+
NuMojo intends to try and get the most out of the capabilities of Mojo including vectorization, parallelization, and GPU acceleration(once available). Currently, NuMojo extends (most of) the standard library math functions to work on tensor inputs.
1757
NuMojo intends to try and get the most out of the capabilities of Mojo including vectorization, parallelization, and GPU acceleration(once available). Currently, NuMojo extends (most of) the standard library math functions to work on tensor inputs.
1858

1959
NuMojo intends to be a building block for other Mojo packages that need fast math under the hood without the added weight of a ML back and forward propagation system
2060

21-
## What NuMojo is not
61+
### What NuMojo is not
2262

2363
NuMojo is not a machine learning library, it will never include back-propagation in the base library.
2464

2565
## Goals / Roadmap
2666

27-
For a detailed roadmap, please check [here](Roadmap.md)
67+
For a detailed roadmap, please refer to the [Roadmap.md](Roadmap.md) file.
68+
69+
Our main goal is to implement a fast, comprehensive numerics library in Mojo. Following are some brief long-term goals,
2870

2971
### Long term goals
30-
* Linear/Tensor Algebra
31-
* Native array types
32-
* Vectorized, Parallelized math operations
33-
* Array manipulation - vstack, slicing, concat etc.
72+
73+
* Linear Algebra
74+
* Native n-dimensional array types
75+
* Vectorized, Parallelized math operations
76+
* Array manipulation - vstack, slicing, concat etc.
3477
* Calculus
35-
* Integration
36-
* Derivates
78+
* Integration & Derivatives etc
3779
* Optimizers
3880
* Function approximators
81+
* Sorting
3982

4083
## Usage
4184

42-
For now
85+
An example goes as follows.
4386

4487
```mojo
45-
import numojo
46-
from tensor import Tensor
47-
def main():
48-
var tens = Tensor[DType.float32](10,10)
49-
tens=tens+numojo.pi/2
50-
print(numojo.sin[DType.float32](tens))
88+
import numojo as nm
89+
90+
fn main() raises:
91+
# Generate two 1000x1000 matrices with random float64 values
92+
var A = nm.NDArray[nm.f64](shape=List[Int](1000,1000), random=True)
93+
var B = nm.NDArray[nm.f64](1000,1000, random=True)
94+
95+
# Print AB
96+
print(nm.linalg.matmul_parallelized(A, B))
5197
```
5298

53-
Please find all the available functions [here](Features.md)
99+
Please find all the available functions [here](features.md)
54100

55101
## How to install
56102

57103
Clone the repository and build
58104

105+
## Contributing
106+
107+
Any contributions you make are **greatly appreciated**. For more details and guidelines on contributions, please check [here](CONTRIBUTING.md)
108+
59109
## Warnings
60110

61111
This library is still very much a work in progress and may change at any time. Also, the standard tensor has many rough edges.
62112

113+
## License
114+
115+
Distributed under the Apache 2.0 License with LLVM Exceptions. See [LICENSE](https://github.com/Mojo-Numerics-and-Algorithms-group/NuMojo/blob/main/LICENSE) and the LLVM [License](https://llvm.org/LICENSE.txt) for more information.
116+
63117
## Acknowledgements
64118

65-
* Built in native [Mojo](https://github.com/modularml/mojo) created by [Modular](https://github.com/modularml)
119+
* Built in native [Mojo](https://github.com/modularml/mojo) which was created by [Modular](https://github.com/modularml)

Roadmap.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,27 @@ Overall the goal is to make a powerful and broad featured library for numerical
44

55
With that in mind NuMojo as a project is in an early stage of development. If you notice a missing feature either build it and make a pull request or make a feature request.
66

7-
### TASKS
7+
## TASKS
8+
89
* Implement tensor version all SIMDable standard library math functions (mostly done waiting on std lib [issue 2492](https://github.com/modularml/mojo/issues/2492))
910
* Build statistics functions
1011
* Build optimizers (newton raphson, bisection,etc)
1112
* Build function approximators
1213

13-
## N Dimensional Arrays
14+
## N-dimensional Arrays
15+
1416
Now that Modular has decided to no longer support Tensor and to open source and deprecate it NuMojo intends to take Tensor and Make it our own Once they do.
1517

1618
Which means that we will be trying to add many of the features from numpy.array that tensor currently lacks, while not sacrificing performance.
1719

1820
## Notional organization of functions and features
21+
1922
* Most common functions at top level like in numpy (trig, basic stats, masking, querying, and mapping)
2023
* Other features should be organized either by type of math or intended utilization
21-
* Statistics probably merits its own sub module
22-
* Regression could either be a submodule of statistics or its own module
23-
* kernel density estimators almost certainly should be part of the statistics sub module
24-
* It is tempting to make a algebra, calculus and trig submodules however that may end up being confusing as those topics include so many things, it may be better to organize what would be there into functional applications instead
25-
* An Ordinary differential equations submodule would include solvers and utilities
26-
* The optimizer sub module could mirror scipy.optimize but minimally should include all of those functions
24+
* Statistics probably merits its own sub module
25+
* Regression could either be a submodule of statistics or its own module
26+
* kernel density estimators almost certainly should be part of the statistics sub module
27+
* It is tempting to make a algebra, calculus and trig submodules however that may end up being confusing as those topics include so many things, it may be better to organize what would be there into functional applications instead
28+
* An Ordinary differential equations submodule would include solvers and utilities
29+
* The optimizer sub module could mirror scipy.optimize but minimally should include all of those functions
2730
* There will need to be discussions and bike shedding about both organization of the library and what does and doesn't belong.

assets/numojo_logo.png

782 KB
Loading

assets/numojo_logo_1.png

788 KB
Loading

base/__init__.mojo

Whitespace-only changes.

base/tensor_func_bit_ops.mojo

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)