Creation
Version: v0.2.0
Status: Complete
Header: include/stratax/core/algorithms/Creation.hpp
Overview
Creation.hpp provides convenience constructors for common tensor initialization patterns.
All helpers return owning Tensor<T> values and require T to satisfy Numeric.
Responsibilities
The creation module is responsible for:
- Creating tensors filled with zeros, ones, or a constant value
- Creating square identity tensors
- Preserving requested output shape semantics
The creation module is not responsible for:
- Returning specialized Vector or Matrix containers
- Lazy/view-based construction
- Randomized initialization policies
Relationships
creation::zeros / ones / full
└── Tensor(shape, value)
creation::identity
├── zeros<T>({size, size})
└── diagonal assignment I(i, i) = T{1}
Depends on:
Invariants
The following conditions are always true:
- All functions return owning stratax::container::Tensor<T>.
- zeros, ones, and full preserve the input shape exactly.
- identity(size) returns a rank-2 square tensor with shape (size, size).
- Identity diagonal entries are T{1} and off-diagonal entries are T{}.
Public Interface
zeros
template<typename T>
Stores an N-dimensional Stratax array in contiguous memory.
Stores a list of dimension lengths for an array shape.
Matches all scalar types supported by Stratax numeric containers.
Creates a tensor filled with T{}.
ones
Creates a tensor filled with T{1}.
full
Creates a tensor filled with value.
identity
Creates a square identity tensor.
Throws
- Propagates constructor/allocation exceptions from Tensor
Complexity Summary
| Operation | Complexity |
| zeros / ones / full | O(n + r) |
| identity(size) | O(size^2) |
n is element count and r is rank.
Examples
const auto I = creation::identity<double>(3);
Design Notes
Keeping these helpers in a small creation namespace provides concise call sites without adding policy complexity to container constructors.
Future Improvements
- Add explicit matrix-returning identity helper if rank-2 specialization is desired
- Add additional builders (arrange, linspace, random initialization) when needed
See Also