1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
//! # Vectra - A multi-dimensional array library for Rust
//!
//! Vectra is a high-performance multi-dimensional array library for Rust, inspired by NumPy.
//! It provides efficient array operations, mathematical functions, and linear algebra capabilities
//! with a focus on performance and ergonomics.
//!
//! ## Features
//!
//! - **Multi-dimensional Arrays**: Support for N-dimensional arrays with flexible indexing
//! - **Broadcasting**: NumPy-style broadcasting for element-wise operations
//! - **Mathematical Functions**: Comprehensive set of mathematical operations including:
//! - Trigonometric functions (sin, cos, tan, etc.)
//! - Hyperbolic functions (sinh, cosh, tanh, etc.)
//! - Logarithmic and exponential functions
//! - Power and root functions
//! - **Linear Algebra**: Matrix multiplication with multiple backend options:
//! - BLAS integration for high performance
//! - Faer backend for pure Rust implementation
//! - Custom optimized implementations
//! - **Random Number Generation**: Built-in support for random array creation
//! - **Memory Efficient**: Zero-copy operations where possible
//! - **Type Safety**: Compile-time dimension checking
//!
//! ## Quick Start
//!
//! ```rust
//! use vectra::prelude::*;
//!
//! // Create arrays
//! let zeros = Array::<_, f64>::zeros([2, 3]);
//! let ones = Array::<_, i32>::ones([3, 3]);
//! let eye = Array::<_, f32>::eye(3); // Identity matrix
//!
//! // Create from vector
//! let data = vec![1, 2, 3, 4, 5, 6];
//! let arr = Array::from_vec(data, [2, 3]);
//!
//! // Array operations
//! let reshaped = arr.reshape([3, 2]);
//! let transposed = arr.transpose();
//!
//! // Mathematical operations
//! let a = Array::from_vec(vec![1.0, 2.0, 3.0, 4.0], [2, 2]);
//! let b = Array::from_vec(vec![5.0, 6.0, 7.0, 8.0], [2, 2]);
//!
//! let sum = &a + &b; // Element-wise addition
//! let product = &a * &b; // Element-wise multiplication
//! let dot_product = a.matmul(&b); // Matrix multiplication
//!
//! // Mathematical functions
//! let angles = Array::from_vec(vec![0.0, std::f64::consts::PI/2.0], [2]);
//! let sines = angles.sin();
//! let exponentials = angles.exp();
//!
//! // Random arrays
//! let random_arr = Array::<_, f64>::random([3, 3]);
//! let normal_arr = Array::<_, f64>::randn([2, 4]);
//! ```
//!
//! ## Array Creation
//!
//! Vectra provides multiple ways to create arrays:
//!
//! ```rust
//! use vectra::prelude::*;
//!
//! // Create arrays filled with specific values
//! let zeros = Array::<_, f64>::zeros([2, 3]);
//! let ones = Array::<_, i32>::ones([3, 3]);
//! let filled = Array::full([2, 2], 42);
//!
//! // Create from existing data
//! let data = vec![1, 2, 3, 4, 5, 6];
//! let arr = Array::from_vec(data, [2, 3]);
//!
//! // Create ranges
//! let range1d = Array::arange(0, 10, 1); // [0, 1, 2, ..., 9]
//! let range_count = Array::arange_c(0, 2, 5); // 5 elements starting from 0 with step 2
//!
//! // Random arrays
//! let random = Array::<_, f64>::random([3, 3]); // Uniform [0, 1)
//! let uniform = Array::uniform([2, 2], -1.0, 1.0); // Uniform [-1, 1)
//! let normal = Array::<_, f64>::randn([2, 3]); // Standard normal distribution
//!
//! // Identity matrix
//! let identity = Array::<_, f64>::eye(4);
//! ```
//!
//! ## Performance
//!
//! Vectra is designed for high performance with multiple optimization strategies:
//!
//! - **BLAS Integration**: Optional BLAS backend for optimized linear algebra operations
//! - **Faer Backend**: Pure Rust high-performance linear algebra
//! - **SIMD Optimizations**: Vectorized operations where supported
//! - **Memory Layout Control**: Support for both row-major and column-major layouts
//! - **Zero-copy Operations**: Efficient memory usage through view-based operations
use ;
use ;
extern crate blas_src;
/// Extension trait for comparison operations that works with both ordered and floating-point types.
///
/// This trait provides a unified interface for comparison operations across different numeric types,
/// handling the special case of floating-point numbers which don't implement `Ord` due to NaN values.
/// A comprehensive numeric trait that combines all necessary numeric operations for array elements.
///
/// This trait serves as a convenient bound that includes all the numeric traits needed for
/// array operations, including basic arithmetic, casting, assignment operations, comparison,
/// copying, debugging, summation, and default values.
///
/// # Automatically Implemented
///
/// This trait is automatically implemented for any type that satisfies all the constituent traits:
/// - `Num`: Basic arithmetic operations
/// - `NumCast`: Numeric type casting
/// - `NumAssign`: Assignment arithmetic operations
/// - `CmpExt`: Extended comparison operations
/// - `Copy`: Efficient copying
/// - `Debug`: Debug formatting
/// - `Sum`: Summation operations
/// - `Default`: Default value construction
impl_cmp_for_ord!;
impl_cmp_for_total_cmp!;
/// Core array implementation and fundamental operations.
/// Mathematical functions and linear algebra operations.
/// Operator overloading for arrays (arithmetic, indexing, etc.).
/// Random number generation and random array creation.
/// Array slicing and view operations.
/// Internal utility functions for array operations.
/// Prelude module that re-exports the most commonly used items.
///
/// This module provides a convenient way to import the essential types and traits
/// needed for most array operations. Import this module to get started quickly:
///
/// ```rust
/// use vectra::prelude::*;
///
/// let arr = Array::from_vec(vec![1, 2, 3, 4], [2, 2]);
/// let result = arr.matmul_with_policy(&arr, MatmulPolicy::default());
/// ```
///
/// ## Re-exported Items
///
/// - [`core::Array`]: The main multi-dimensional array type
/// - [`math::MatmulPolicy`]: Policy for choosing matrix multiplication backend
/// - [`math::matmul::Matmul`]: Trait providing matrix multiplication methods