diff --git a/README.md b/README.md index 2e68dfd..05bbd83 100644 --- a/README.md +++ b/README.md @@ -36,32 +36,30 @@ For variables `x`, `y`, and `result`, all of type `Span` and of the same Tensor.Add(x, y, result); ``` -In addition to per-element operations, the library also provides support for various aggregation operations, including: +In addition to working with individual elements, this library supports various aggregation operations. For example: ```csharp -var sum = TensorOperations.Sum(values); -var average = TensorOperations.Average(values); -var product = TensorOperations.Product(values); -var min = TensorOperations.Min(values); -var max = TensorOperations.Max(values); -var (minIndex, maxIndex) = TensorOperations.MinMax(values); +var sum = TensorOperations.Sum(data); +var min = TensorOperations.Min(data); +var (min, max) = TensorOperations.MinMax(data); ``` -Furthermore, the library offers functionality to retrieve the index of specific elements: +It also helps find the index of specific elements: ```csharp -var indexOfMin = TensorOperations.IndexOfMin(values); -var indexOfMax = TensorOperations.IndexOfMax(values); +var index = TensorOperations.IndexOfMin(data); ``` -It also facilitates finding the index of the first element meeting a particular condition: +Additionally, it can quickly locate the first element meeting certain criteria: ```csharp -var indexOfEqualToZero = IndexOfEquals(values, 0); -var indexOfGreaterThanZero = IndexOfGreaterThan(values, 0); -var indexOfGreaterThanOrEqualToZero = IndexOfGreaterThanOrEqual(values, 0); -var indexOfLessThanZero = IndexOfLessThan(values, 0); -var indexOfLessThanOrEqualToZero = IndexOfLessThanOrEqual(values, 0); +var value = FirstGreaterThan(data, 0); +``` + +And it simplifies finding the index of such elements: + +```csharp +var index = IndexOfFirstGreaterThan(data, 0); ``` ### Custom Operations @@ -78,4 +76,4 @@ This project relies on the following open-source projects: ## License -This project is licensed under the MIT license. Refer to the [LICENSE](LICENSE) file for details. \ No newline at end of file +This project is licensed under the MIT license. Refer to the [LICENSE](LICENSE) file for details. diff --git a/docs/articles/Getting-started.md b/docs/articles/Getting-started.md index 87d1bbd..e7524ff 100644 --- a/docs/articles/Getting-started.md +++ b/docs/articles/Getting-started.md @@ -27,32 +27,30 @@ TensorOperations.Add(x, y, result); > **NOTE**: The operations do not allocate any memory, ensuring optimal performance. The library is designed to be memory-efficient and performant. All the spans have to be allocated and managed by the user. -In addition to per-element operations, the library also provides support for various aggregation operations, including: +In addition to working with individual elements, this library supports various aggregation operations. For example: ```csharp -var sum = TensorOperations.Sum(values); -var average = TensorOperations.Average(values); -var product = TensorOperations.Product(values); -var min = TensorOperations.Min(values); -var max = TensorOperations.Max(values); -var (minIndex, maxIndex) = TensorOperations.MinMax(values); +var sum = TensorOperations.Sum(data); +var min = TensorOperations.Min(data); +var (min, max) = TensorOperations.MinMax(data); ``` -Furthermore, the library offers functionality to retrieve the index of specific elements: +It also helps find the index of specific elements: ```csharp -var indexOfMin = TensorOperations.IndexOfMin(values); -var indexOfMax = TensorOperations.IndexOfMax(values); +var index = TensorOperations.IndexOfMin(data); ``` -It also facilitates finding the index of the first element meeting a particular condition: +Additionally, it can quickly locate the first element meeting certain criteria: ```csharp -var indexOfEqualToZero = IndexOfEquals(values, 0); -var indexOfGreaterThanZero = IndexOfGreaterThan(values, 0); -var indexOfGreaterThanOrEqualToZero = IndexOfGreaterThanOrEqual(values, 0); -var indexOfLessThanZero = IndexOfLessThan(values, 0); -var indexOfLessThanOrEqualToZero = IndexOfLessThanOrEqual(values, 0); +var value = FirstGreaterThan(data, 0); +``` + +And it simplifies finding the index of such elements: + +```csharp +var index = IndexOfFirstGreaterThan(data, 0); ``` Dive deeper into the library's capabilities by exploring the API documentation, especially the section under the `TensorOperations` type, for an exhaustive list of available functionalities. diff --git a/src/NetFabric.Numerics.Tensors/README.md b/src/NetFabric.Numerics.Tensors/README.md index 2d6a904..fe17420 100644 --- a/src/NetFabric.Numerics.Tensors/README.md +++ b/src/NetFabric.Numerics.Tensors/README.md @@ -1,12 +1,12 @@ # NetFabric.Numerics.Tensors -Dealing with SIMD in .NET for optimized code can be complex, but this library offers a practical solution. It provides a reusable and highly-optimized iterations on `Span`, enabling the application of both pre-defined and custom operations to each element. +Working with SIMD in .NET to optimize code can be challenging, but this library offers a straightforward solution. It delivers reusable and highly optimized iterations over `Span`, allowing for the application of both pre-defined and custom operations to each element or aggregation of elements. Using generics, the library accommodates any type embracing [.NET generic math](https://learn.microsoft.com/en-us/dotnet/standard/generics/math). -Within the library, you'll find pre-defined operations such as `Sqrt()`, `Sin()`, `Negate()`, `Add()`, `Divide()`, `Multiply()`, `AddMultiply()`, `Sum()`, `Average()`, and many more. +Within the library, you'll find pre-defined operations such as `Sqrt()`, `Sin()`, `Negate()`, `Add()`, `Divide()`, `Multiply()`, `AddMultiply()`, `Sum()`, `Average()`, `Min()`, `Max()`, and many more. -For custom operations, the library allows the definition of operators through interfaces like `IUnaryOperator`, `IBinaryOperator`, `ITernaryOperator`, or `IAggregationOperator`. These operators can be applied seamlessly using the `Apply()` or `Aggregate()` methods. +For custom operations, the library allows the definition of operators through interfaces like `IUnaryOperator`, `IBinaryOperator`, `ITernaryOperator`, or `IAggregationOperator`. These operators can be applied seamlessly using the `Apply()`, `Aggregate()`, `IndexOfAggregate()`, `First()`, or `IndexOfFirst()` methods. ## Usage @@ -26,34 +26,34 @@ Given variables `x`, `y`, and `result`, all of type `Span` and of the sam TensorOperations.Add(x, y, result); ``` -In addition to per-element operations, the library also provides support for various aggregation operations, including: +In addition to working with individual elements, this library supports various aggregation operations. For example: ```csharp -var sum = TensorOperations.Sum(values); -var average = TensorOperations.Average(values); -var product = TensorOperations.Product(values); -var min = TensorOperations.Min(values); -var max = TensorOperations.Max(values); -var (minIndex, maxIndex) = TensorOperations.MinMax(values); +var sum = TensorOperations.Sum(data); +var min = TensorOperations.Min(data); +var (min, max) = TensorOperations.MinMax(data); ``` -Furthermore, the library offers functionality to retrieve the index of specific elements: +It also helps find the index of specific elements: ```csharp -var indexOfMin = TensorOperations.IndexOfMin(values); -var indexOfMax = TensorOperations.IndexOfMax(values); +var index = TensorOperations.IndexOfMin(data); ``` -It also facilitates finding the index of the first element meeting a particular condition: +Additionally, it can quickly locate the first element meeting certain criteria: ```csharp -var indexOfEqualToZero = IndexOfEquals(values, 0); -var indexOfGreaterThanZero = IndexOfGreaterThan(values, 0); -var indexOfGreaterThanOrEqualToZero = IndexOfGreaterThanOrEqual(values, 0); -var indexOfLessThanZero = IndexOfLessThan(values, 0); -var indexOfLessThanOrEqualToZero = IndexOfLessThanOrEqual(values, 0); +var value = FirstGreaterThan(data, 0); +``` + +And it simplifies finding the index of such elements: + +```csharp +var index = IndexOfFirstGreaterThan(data, 0); ``` ## Custom Operations -While `NetFabric.Numerics.Tensors` provides various pre-defined operations, combining them might not be efficient. Custom operators can be implemented, allowing the definition of specific operations for each element of the source, while still benefiting from high-performance reusable iteration code. +While `NetFabric.Numerics.Tensors` provides various pre-defined operations, combining them might not be efficient. Custom operators can be implemented, allowing the definition of specific operations for each element of the source, while still benefiting from high-performance reusable iteration code. + +The aggregation methods support transformation operators that allow composite operations to be performed in a single data iteration.