Skip to content

Commit

Permalink
Update READMEs
Browse files Browse the repository at this point in the history
  • Loading branch information
aalmada committed Apr 4, 2024
1 parent 6724248 commit 3bb774b
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 53 deletions.
32 changes: 15 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,32 +36,30 @@ For variables `x`, `y`, and `result`, all of type `Span<float>` 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
Expand All @@ -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.
This project is licensed under the MIT license. Refer to the [LICENSE](LICENSE) file for details.
30 changes: 14 additions & 16 deletions docs/articles/Getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
40 changes: 20 additions & 20 deletions src/NetFabric.Numerics.Tensors/README.md
Original file line number Diff line number Diff line change
@@ -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<T>`, 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<T>`, 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<T>`, `IBinaryOperator<T>`, `ITernaryOperator<T>`, or `IAggregationOperator<T>`. 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<T>`, `IBinaryOperator<T>`, `ITernaryOperator<T>`, or `IAggregationOperator<T>`. These operators can be applied seamlessly using the `Apply()`, `Aggregate()`, `IndexOfAggregate()`, `First()`, or `IndexOfFirst()` methods.

## Usage

Expand All @@ -26,34 +26,34 @@ Given variables `x`, `y`, and `result`, all of type `Span<float>` 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.

0 comments on commit 3bb774b

Please sign in to comment.