Skip to content

vtl #

VTL tensor network logo

The V Tensor Library

[![Mentioned in Awesome V][awesomevbadge]][awesomevurl] [![CI][workflowbadge]][workflowurl] [![Docs][docsbadge]][docsurl] [![Full ML][fullmlbadge]][fullmlurl] [![Benchmarks][benchmarksbadge]][benchmarksurl] [![License: MIT][licensebadge]][licenseurl] ![VSL Backed][vslbackedbadge] ![CUDA Optional][cudaoptionalbadge] ![Vulkan f32][vulkanbadge]

VTL is a pure-V tensor library for numerical computing and machine learning — n-dimensional arrays, autograd, linear algebra via VSL, and a full neural network module.

Train small neural networks, experiment with autograd, and use VSL-backed CPU, CUDA, and Vulkan compute paths from one V-native API.

vlang.io | Docs | Tutorials | NumPy/ML migration | Histograms | PyTorch parity | Burn comparison | ML Roadmap | Contributing | VSL

<img src="static/vtl-feature-banner.svg" alt="VTL tensors, autograd, numerical computing, and CPU and GPU training paths" width="100%"

VTL and VSL architecture

VTL tensor, VSL kernel, and compute backend architecture

View SVG source · PNG

import vtl
t := vtl.from_array([1.0, 2, 3, 4], [2, 2])!
t.get([1, 1])
// 4.0

Features

  • Tensors — create, slice, indexed take/take_nd/take_flat/put, choose/select, round_decimals, nan_to_num, compress, indices, pad, set membership, reshape, transpose, move/roll axes, N-D diagonal views, NumPy-style Kronecker products, broadcast, map/reduce, einsum, and complex128 storage with elementwise and matrix products
  • Autograd — reverse-mode AD; arbitrary computational graphs
  • Neural networks — Sequential API; Linear, Conv2D, LSTM, Attention, …
  • Losses & optimizers — MSE, MAE, BCE, Hinge, Focal, CrossEntropy, Huber; Adam, AdamW, NAdam, RAdam, SGD, …
  • Linear algebra — VSL-backed real matmul and general eigensolvers, pure-V complex128 matmul, solve, QR, LU, Cholesky, SVD, pinv
  • Hardware — zero-copy Tensor.data for C libs; optional CUDA and Vulkan training paths

ML Release Highlights

The ML beta scope is the high-level VTL API: tensors, autograd, layers, losses, optimizers, datasets, and CPU training. CUDA and Vulkan paths are available for opt-in validation and early adopters, but remain experimental backend accelerators rather than stable user contracts.

Area Status
f32 training Sequential + MSE + Adam smoke tests
CUDA Experimental opt-in Linear/Conv2D forward; f64 Linear/Conv2D/Dropout backward; activation chain and Adam slots
Vulkan Experimental opt-in f32 Linear, Conv2D same-padding, ReLU/Sigmoid/Softplus/SELU/HardSwish, fused Adam shader
Datasets MNIST, IMDB, CIFAR-10 loaders plus CI-safe synthetic examples
Benchmarks VTL vs NumPy/PyTorch scripts and PR benchmark workflow

For memory-safe local commands, see DEV_LIGHTWEIGHT.md.

Quick start

import vtl
import vtl.autograd
import vtl.nn.layers
import vtl.nn.models
import vtl.nn.optimizers

mut ctx := autograd.ctx[f32]()
mut model := models.sequential_from_ctx[f32](ctx)
model.input([784])
model.linear(256)
model.linear(10)
model.mse_loss()

input_tensor := vtl.zeros[f32]([64, 784])
mut x := ctx.variable(input_tensor)
y_pred := model.forward(x)!

target := vtl.zeros[f32]([64, 10])
mut loss_val := model.loss(y_pred, target)!
loss_val.backprop()!

mut opt := optimizers.adam_optimizer[f32](optimizers.AdamOptimizerConfig{
    learning_rate: 0.001
})
opt.build_params(model.info.layers)
opt.update()!

Module overview

Module Purpose Guide
vtl Tensor creation, slicing, broadcasting, reductions First steps
vtl.array_api Explicit, capability-discoverable Python Array API subset Array API namespace
Complex tensors math.complex.Complex storage and elementwise arithmetic Complex tensors
vtl.fft Real and complex FFTs via VSL PocketFFT FFT
vtl.csv Numeric CSV tensor input and output NumPy I/O
vtl.npy / vtl.npz Typed NumPy array and archive I/O NumPy I/O
vtl.autograd Differentiable operations and backpropagation Autograd
vtl.autograd_cuda Optional CUDA autograd Device memory
vtl.la VSL-backed linear algebra Linear algebra
vtl.nn Layers, losses, optimizers, and training Neural networks
vtl.nn.models Model construction, training, serialization Neural networks
vtl.nn.layers Dense, convolutional, recurrent, and attention layers Neural networks
vtl.nn.loss Regression and classification losses Neural networks
vtl.nn.optimizers Optimizers and learning-rate schedulers Optimizers
vtl.nn.data Neural-network data loaders Examples
vtl.nn.internal Internal tensor and activation operations Source
vtl.nn.gates Neural-network autograd gates Autograd
vtl.datasets MNIST, CIFAR-10, and IMDB loaders Datasets
vtl.stats Averages, descriptive statistics, and summaries Reductions
Core lookup Unique values, indexing, and set operations Indexing
vtl.ml.metrics Machine-learning metrics and evaluation Source
vtl.storage CPU, CUDA, VCL, and Vulkan storage Device memory

Device naming

Device families and ordinals live in the root vtl module, beside tensors and dtypes: vtl.parse_device('cuda:0')! returns a DeviceRef with private, validated fields and accessors (family(), ordinal(), has_explicit_ordinal(), name()). compiled() reports whether the build includes that backend using the same flags as tensor transfer paths (-d cuda, -d vulkan, -d vcl for OpenCL/VCL). ensure_available() also checks the runtime device count, so an out-of-range ordinal such as cuda:99 is rejected.

import vtl

device := vtl.parse_device('cuda:0')!
device.ensure_available()!
println(device.name())

Installation

VTL uses VSL for linear algebra. The core vtl module works without optional system BLAS/LAPACK, but LA features need VSL.

Follow VSL install instructions, then:

v install vtl

Testing

# Run the full scoped suite from ~/.vmodules; compiler parallelism is disabled
# to keep the local memory ceiling predictable.
cd ~/.vmodules
systemd-run --user --scope --property=MemoryMax=4G --property=MemorySwapMax=0 \
    env VJOBS=2 VTL_NO_PARALLEL=1 ./vtl/bin/test

See DEV_LIGHTWEIGHT.md for memory-safe subsets in CI. See PAIRED_RELEASES.md for VTL/VSL candidate release validation.

Documentation

Start Here

Goal Read
Learn tensors First steps
Learn autograd Autograd tutorial
Build neural networks Neural networks
Pick optimizers Optimizers
Run examples Examples catalog
Use datasets Datasets
Exchange NumPy .npy arrays .npy input/output
Quantize tensors for INT8 inference Quantization API, example
Load numeric CSV data CSV and NumPy I/O
Use GPU paths safely DEV_LIGHTWEIGHT.md, DEVICE_MEMORY.md
Tutorial Topic
TUTORIAL_FIRST_STEPS.md Tensor creation, indexing, slicing
TUTORIAL_MATH_UFUNCS.md NumPy-style elementwise math and binary decomposition
TUTORIAL_MAP_REDUCE.md map / nmap and reductions
TUTORIAL_AUTOGRAD.md Variable, gates, backprop
TUTORIAL_REDUCTIONS.md argmax / argmin / cumsum
TUTORIAL_NEURAL_NETWORKS.md Layers, losses, Sequential
TUTORIAL_OPTIMIZERS.md Adam, AdamW, RMSProp, schedulers
TUTORIAL_LINEAR_ALGEBRA.md LA basics via VSL
TUTORIAL_FFT.md One-dimensional real Fourier transforms via PocketFFT
TUTORIAL_ADVANCED_LA.md QR, LU, Cholesky, pinv
TUTORIAL_BROADCASTING.md Broadcasting rules
TUTORIAL_SLICING.md Slicing and views

Full index: docs/README.md.

Contributors

VTL's early development was inspired by vnum, part of the Vlang Num group, and the work of Christopher Zimmerman. The core was reimplemented while keeping that lineage and inspiration. The original vnum work carried a BSD 3-Clause license with attribution to vlang-num contributors; the historical license text is preserved in the VTL repository history. This acknowledgment records that history and does not change VTL's current license, shown below.

VTL contributors

Made with contributors-img.

License

MIT

[awesomevbadge]: https://awesome.re/mentioned-badge.svg [workflowbadge]: https://github.com/vlang/vtl/actions/workflows/ci.yml/badge.svg [docsbadge]: https://github.com/vlang/vtl/actions/workflows/deploy-docs.yml/badge.svg [fullmlbadge]: https://github.com/vlang/vtl/actions/workflows/ci-full-ml.yml/badge.svg [benchmarksbadge]: https://github.com/vlang/vtl/actions/workflows/benchmark-pr-comment.yml/badge.svg [licensebadge]: https://img.shields.io/badge/License-MIT-blue.svg [vslbackedbadge]: https://img.shields.io/badge/VSL-backed-027d9c?logo=v [cudaoptionalbadge]: https://img.shields.io/badge/CUDA-optional-76b900?logo=nvidia [vulkanbadge]: https://img.shields.io/badge/Vulkan-f32-ac162c?logo=vulkan [awesomevurl]: https://github.com/vlang/awesome-v/blob/master/README.md#scientific-computing [workflowurl]: https://github.com/vlang/vtl/actions/workflows/ci.yml [docsurl]: https://github.com/vlang/vtl/actions/workflows/deploy-docs.yml [fullmlurl]: https://github.com/vlang/vtl/actions/workflows/ci-full-ml.yml [benchmarksurl]: https://github.com/vlang/vtl/actions/workflows/benchmark-pr-comment.yml [licenseurl]: https://github.com/vlang/vtl/blob/main/LICENSE

fn abs #

fn abs(input &Tensor[complex.Complex]) !&Tensor[f64]

abs is the NumPy-style alias for absolute.

fn absolute #

fn absolute(input &Tensor[complex.Complex]) !&Tensor[f64]

absolute returns the magnitude of every complex element as a float64 tensor. math.hypot scales its inputs to avoid unnecessary overflow and underflow.

fn acos_promoted #

fn acos_promoted[R, T](t &Tensor[T]) !&Tensor[R]

acos_promoted computes elementwise inverse cosine values using the same output dtype rules as sqrt_promoted.

fn acosh_promoted #

fn acosh_promoted[R, T](t &Tensor[T]) !&Tensor[R]

acosh_promoted computes elementwise inverse hyperbolic cosine using the same output dtype rules as sqrt_promoted.

fn add_promoted #

fn add_promoted[R, T, U](a &Tensor[T], b &Tensor[U]) !&Tensor[R]

add_promoted adds real numeric or boolean tensors after converting both operands to the explicitly selected NumPy-style result dtype. The output type R must match the operation's NumPy result dtype.

fn add_scalar_left_promoted #

fn add_scalar_left_promoted[R, T, U](scalar U, a &Tensor[T]) !&Tensor[R]

add_scalar_left_promoted adds a tensor to a weak numeric or complex scalar using NumPy-style promotion.

fn add_scalar_promoted #

fn add_scalar_promoted[R, T, U](a &Tensor[T], scalar U) !&Tensor[R]

add_scalar_promoted adds a weak numeric or complex scalar using NumPy-style promotion. R must be the inferred result dtype; this explicit type is required by V's statically typed generic return values.

fn advanced_index #

fn advanced_index[T](t &Tensor[T], indices []&Tensor[int]) !&Tensor[T]

advanced_index selects values using one integer coordinate tensor per input axis. Coordinate tensors are broadcast together, and each output element is read from the matching coordinate tuple. The result is an independent row-major copy. This API handles full coordinate tuples; mixing coordinate tensors with slices or scalar indices is not supported here.

fn arange #

fn arange[T](start f64, stop f64, step f64, params TensorData) !&Tensor[T]

arange returns evenly spaced values in the half-open interval [start, stop). The direction of step determines whether the result is ascending or descending.

fn arccos #

fn arccos(input &Tensor[complex.Complex]) !&Tensor[complex.Complex]

arccos applies the principal inverse complex cosine to every element.

fn arccosh #

fn arccosh(input &Tensor[complex.Complex]) !&Tensor[complex.Complex]

arccosh applies the principal inverse complex hyperbolic cosine to every element.

fn arcsin #

fn arcsin(input &Tensor[complex.Complex]) !&Tensor[complex.Complex]

arcsin applies the principal inverse complex sine to every element.

fn arcsinh #

fn arcsinh(input &Tensor[complex.Complex]) !&Tensor[complex.Complex]

arcsinh applies the principal inverse complex hyperbolic sine to every element.

fn arctan #

fn arctan(input &Tensor[complex.Complex]) !&Tensor[complex.Complex]

arctan applies the principal inverse complex tangent to every element.

fn arctanh #

fn arctanh(input &Tensor[complex.Complex]) !&Tensor[complex.Complex]

arctanh applies the principal inverse complex hyperbolic tangent to every element.

fn argpartition #

fn argpartition[T](t &Tensor[T], kth int) !&Tensor[int]

argpartition returns local indices that place kth at its sorted position along the last axis. The order of the other indices is unspecified.

fn argpartition_axis #

fn argpartition_axis[T](t &Tensor[T], kths []int, axis int) !&Tensor[int]

argpartition_axis partially orders local indices along axis. The returned tensor has the same shape as t and supports multiple kth positions.

fn argsort #

fn argsort[T](t &Tensor[T]) !&Tensor[int]

argsort returns stable ascending sort indices along the last axis.

fn argsort_axis #

fn argsort_axis[T](t &Tensor[T], axis int) !&Tensor[int]

argsort_axis returns the stable ascending sort indices along axis. Returned indices are local to that axis; floating-point NaNs sort to the end.

fn argwhere #

fn argwhere[T](t &Tensor[T]) !&Tensor[int]

argwhere returns the coordinates of non-zero elements as a row-major tensor with shape [number of matches, input rank].

fn array_index #

fn array_index(indices &Tensor[int]) TensorIndex

array_index selects positions using an integer coordinate tensor. All coordinate tensors in a mixed_index call are broadcast together.

fn asin_promoted #

fn asin_promoted[R, T](t &Tensor[T]) !&Tensor[R]

asin_promoted computes elementwise inverse sine values using the same output dtype rules as sqrt_promoted.

fn asinh_promoted #

fn asinh_promoted[R, T](t &Tensor[T]) !&Tensor[R]

asinh_promoted computes elementwise inverse hyperbolic sine using the same output dtype rules as sqrt_promoted.

fn atan2_promoted #

fn atan2_promoted[R, T, U](y &Tensor[T], x &Tensor[U]) !&Tensor[R]

atan2_promoted computes elementwise atan2 for real numeric or boolean tensors. It returns float64 when either input is float64 or a >=32-bit integer; other results use float32. NumPy float16 results for booleans and <=8-bit integers are widened because VTL does not support float16.

fn atan_promoted #

fn atan_promoted[R, T](t &Tensor[T]) !&Tensor[R]

atan_promoted computes elementwise inverse tangent values using the same output dtype rules as sqrt_promoted.

fn atanh_promoted #

fn atanh_promoted[R, T](t &Tensor[T]) !&Tensor[R]

atanh_promoted computes elementwise inverse hyperbolic tangent using the same output dtype rules as sqrt_promoted.

fn bernoulli #

fn bernoulli[T](prob f64, shape []int, params TensorData) &Tensor[T]

bernoulli returns a tensor of bernoulli random variables.

fn beta #

fn beta(alpha f64, beta f64, shape []int, params TensorData) !&Tensor[f64]

beta returns samples from the Beta distribution using VTL's global stream.

fn binary_promoted_auto #

fn binary_promoted_auto[T, U](a &Tensor[T], b &Tensor[U], operation PromotedArithmetic) !PromotedTensor

binary_promoted_auto selects the NumPy-style result dtype at runtime. The returned sum type preserves the concrete tensor dtype for callers that need statically typed values; use promoted_tensor_dtype or match on the result.

fn binomial #

fn binomial[T](n int, prob f64, shape []int, params TensorData) !&Tensor[T]

binomial returns a tensor of binomial random variables.

fn boolean_index #

fn boolean_index[T](t &Tensor[T], mask &Tensor[bool]) !&Tensor[T]

boolean_index selects values where mask is true. The mask shape must match the leading tensor dimensions; any remaining tensor dimensions are retained after the selected-element axis. The result is an independent row-major copy, matching NumPy's a[mask] behavior.

fn broadcast2 #

@[inline]
fn broadcast2[T](a &Tensor[T], b &Tensor[T]) !(&Tensor[T], &Tensor[T])

broadcast2 exposes this operation as part of the public API.

fn broadcast3 #

@[inline]
fn broadcast3[T](a &Tensor[T], b &Tensor[T], c &Tensor[T]) !(&Tensor[T], &Tensor[T], &Tensor[T])

broadcast3 exposes this operation as part of the public API.

fn broadcast_n #

@[inline]
fn broadcast_n[T](ts []&Tensor[T]) ![]&Tensor[T]

broadcast_n exposes this operation as part of the public API.

fn cast #

fn cast[T](x TensorDataType) T

cast exposes this operation as part of the public API.

fn cauchy #

fn cauchy(location f64, scale f64, shape []int, params TensorData) !&Tensor[f64]

cauchy returns samples from a Cauchy distribution using VTL's global stream.

fn cbrt_promoted #

fn cbrt_promoted[R, T](t &Tensor[T]) !&Tensor[R]

cbrt_promoted computes elementwise cube roots using the same output dtype rules as sqrt_promoted.

fn ceil_promoted #

fn ceil_promoted[R, T](t &Tensor[T]) !&Tensor[R]

ceil_promoted returns elementwise ceilings while preserving the input dtype.

fn chebyshev #

fn chebyshev(coefficients []f64, domain [2]f64, window [2]f64) !Chebyshev

chebyshev constructs a first-kind Chebyshev series from ascending coefficients and domain/window bounds.

fn chebyshev_fit #

fn chebyshev_fit(x []f64, y []f64, degree int, domain [2]f64, window [2]f64) !Chebyshev

chebyshev_fit computes a least-squares Chebyshev fit of the given degree over domain and window.

fn chebyshev_from_polynomial #

fn chebyshev_from_polynomial(p Polynomial, domain [2]f64, window [2]f64) !Chebyshev

chebyshev_from_polynomial converts a power-series Polynomial into the Chebyshev basis on domain and window.

fn chi_square #

fn chi_square(degrees_of_freedom f64, shape []int, params TensorData) !&Tensor[f64]

chi_square returns samples from a chi-square distribution using VTL's global random stream.

fn choose #

fn choose[T](indices &Tensor[int], choices []&Tensor[T]) !&Tensor[T]

choose selects values from choices using integer indices. Choices broadcast to one common shape, and indices broadcast to that shape. Each index must be in the range [0, choices.len).

fn clip_tensor #

fn clip_tensor[T](t &Tensor[T], lower &Tensor[T], upper &Tensor[T]) !&Tensor[T]

clip_tensor clamps values using broadcastable lower and upper bounds. It computes the result in one pass so callers do not need separate maximum and minimum tensors or intermediate results. Stride-based offsets avoid creating per-element coordinate arrays, including when an input is a view.

fn column_stack #

fn column_stack[T](ts []&Tensor[T]) !&Tensor[T]

column_stack stacks 1-D arrays as columns into a 2-D array.

fn compiled_with #

fn compiled_with(device Device, flags []string) bool

compiled_with is the build-capability policy for a device family, given the active compile-time flags. It is split out from compiled() so the policy can be tested without building each accelerator backend.

fn complex_angle #

fn complex_angle(input &Tensor[complex.Complex], degrees bool) !&Tensor[f64]

complex_angle returns the phase of each value in radians, or degrees when requested. The result range follows atan2 and is [-pi, pi].

fn complex_is_finite #

fn complex_is_finite(input &Tensor[complex.Complex]) !&Tensor[bool]

complex_is_finite reports whether both components of each value are finite.

fn complex_is_inf #

fn complex_is_inf(input &Tensor[complex.Complex]) !&Tensor[bool]

complex_is_inf reports whether either component of each value is infinite.

fn complex_is_nan #

fn complex_is_nan(input &Tensor[complex.Complex]) !&Tensor[bool]

complex_is_nan reports whether either component of each value is NaN.

fn compress #

fn compress[T](condition &Tensor[bool], t &Tensor[T]) !&Tensor[T]

compress selects flattened values at positions where condition is true. As in NumPy, a condition shorter than the input stops selection at its length; extra condition values are ignored.

fn compress_axis #

fn compress_axis[T](condition &Tensor[bool], t &Tensor[T], axis int) !&Tensor[T]

compress_axis selects slices along axis using a one-dimensional condition. If condition is shorter than the axis, the remaining slices are omitted.

fn concatenate #

fn concatenate[T](ts []&Tensor[T], data AxisData) !&Tensor[T]

concatenate concatenates two Tensors together

fn conj #

fn conj(input &Tensor[complex.Complex]) !&Tensor[complex.Complex]

conj returns the complex conjugate of every element in a complex tensor.

fn copysign #

fn copysign[T](magnitude &Tensor[T], sign &Tensor[T]) !&Tensor[T]

copysign returns the magnitude of magnitude with the sign bit of sign. Both f32 and f64 inputs broadcast to a common output shape.

fn copysign_promoted #

fn copysign_promoted[R, T, U](magnitude &Tensor[T], sign &Tensor[U]) !&Tensor[R]

copysign_promoted applies the sign bit of a real numeric or boolean tensor to another tensor's magnitude, with NumPy-style float output promotion.

fn cos #

fn cos(input &Tensor[complex.Complex]) !&Tensor[complex.Complex]

cos applies the complex cosine to every element.

fn cos_promoted #

fn cos_promoted[R, T](t &Tensor[T]) !&Tensor[R]

cos_promoted computes elementwise cosine values using the same output dtype rules as sqrt_promoted.

fn cosh #

fn cosh(input &Tensor[complex.Complex]) !&Tensor[complex.Complex]

cosh applies the complex hyperbolic cosine to every element.

fn cosh_promoted #

fn cosh_promoted[R, T](t &Tensor[T]) !&Tensor[R]

cosh_promoted computes elementwise hyperbolic cosine values using the same output dtype rules as sqrt_promoted.

fn count_nonzero #

@[direct_array_access]
fn count_nonzero[T](t &Tensor[T]) int

count_nonzero counts non-zero values across every tensor dimension.

fn count_nonzero_axes #

fn count_nonzero_axes[T](t &Tensor[T], axes []int, keepdims bool) !&Tensor[int]

count_nonzero_axes counts non-zero values along multiple axes. Negative axes are supported, axes must be unique, and an empty axis list preserves the input shape while converting each value to zero or one.

fn count_nonzero_axis #

fn count_nonzero_axis[T](t &Tensor[T], axis int, keepdims bool) !&Tensor[int]

count_nonzero_axis counts non-zero values along one axis. By default the reduced axis is removed; set keepdims to retain it with length one.

fn cpu_device #

fn cpu_device() DeviceRef

cpu_device returns the always-available CPU device.

fn degrees_promoted #

fn degrees_promoted[R, T](t &Tensor[T]) !&Tensor[R]

degrees_promoted converts radians to degrees with NumPy-style float output promotion.

fn device_candidates #

fn device_candidates() []DeviceRef

device_candidates lists all supported device families for discovery.

fn device_count #

fn device_count(device Device) !int

device_count probes the runtime for the number of addressable devices of a family. CPU has one; CUDA and OpenCL/VCL ask their backend. Vulkan exposes a single default device in vsl.vulkan (no ordinal selection), so only ordinal zero is valid there.

fn diagonal #

fn diagonal[T](input &Tensor[T], params DiagonalData) !&Tensor[T]

diagonal returns a view along the diagonal of two axes of an N-D tensor. The selected axes are removed and the diagonal axis is appended to the result, following NumPy's shape convention. The view shares input storage. VTL tensors remain mutable, so writes through the result update the input.

fn diagonal_readonly #

fn diagonal_readonly[T](input &Tensor[T], params DiagonalData) !&ReadOnlyDiagonalView[T]

diagonal_readonly returns a storage-sharing diagonal view with a read-only API. The legacy diagonal function remains writable for compatibility.

fn diff #

fn diff[T](t &Tensor[T], n int, axis int) !&Tensor[T]

diff computes the n-th discrete difference along an axis. Negative axes count from the end, and n=0 returns a row-major copy of the input.

fn digitize #

fn digitize[T](values &Tensor[T], bins &Tensor[T], right bool) !&Tensor[int]

digitize assigns values to monotonic bins. Increasing and decreasing edge arrays are supported; right selects which interval owns an edge value.

fn dirichlet #

fn dirichlet[T](alpha &Tensor[T], sample_shape []int, params TensorData) !&Tensor[f64]

dirichlet returns normalized Gamma samples. The final output axis contains categories and sample_shape defines the preceding axes.

fn divide_promoted #

fn divide_promoted[R, T, U](a &Tensor[T], b &Tensor[U]) !&Tensor[R]

divide_promoted performs NumPy-style true division for numeric tensors and booleans. Complex inputs produce complex128; real inputs produce float32 only when the promoted input dtype is float32, and float64 otherwise.

fn divide_scalar_left_promoted #

fn divide_scalar_left_promoted[R, T, U](scalar U, a &Tensor[T]) !&Tensor[R]

divide_scalar_left_promoted performs NumPy-style true division with a weak scalar as the numerator.

fn divide_scalar_promoted #

fn divide_scalar_promoted[R, T, U](a &Tensor[T], scalar U) !&Tensor[R]

divide_scalar_promoted performs true division by a weak numeric scalar using NumPy-style promotion. R must be the inferred result dtype.

fn dstack #

fn dstack[T](ts []&Tensor[T]) !&Tensor[T]

dstack stacks arrays in sequence depth wise (along third axis)

fn dtype_of #

fn dtype_of[T]() DType

dtype_of returns the VTL dtype corresponding to the compile-time type T.

fn einsum #

fn einsum[T](subscripts string, operands ...&Tensor[T]) !&Tensor[T]

einsum evaluates an Einstein summation expression over one or more tensors. It supports alphabetic axis labels, explicit or implicit output labels, repeated labels for diagonals, broadcasting of size-one axes, and any number of operands. Ellipses expand to the leading axes and are right-aligned across operands, enabling batched expressions such as ...ij,...jk->...ik.

When the output is omitted, labels that occur exactly once are returned in alphabetical order, following NumPy's implicit-output convention.

fn ellipsis_index #

fn ellipsis_index() TensorIndex

ellipsis_index expands to enough full axes to cover the unindexed dimensions. At most one ellipsis is allowed in a mixed_index call.

fn empty #

@[inline]
fn empty[T](shape []int, params TensorData) &Tensor[T]

empty exposes this operation as part of the public API.

fn empty_like #

@[inline]
fn empty_like[T](t &Tensor[T]) &Tensor[T]

empty_like exposes this operation as part of the public API.

fn exp #

fn exp(input &Tensor[complex.Complex]) !&Tensor[complex.Complex]

exp applies the complex exponential to every complex tensor element.

fn exp2_promoted #

fn exp2_promoted[R, T](t &Tensor[T]) !&Tensor[R]

exp2_promoted computes elementwise powers of two using the same output dtype rules as sqrt_promoted.

fn exp_promoted #

fn exp_promoted[R, T](t &Tensor[T]) !&Tensor[R]

exp_promoted computes elementwise exponential values using the same output dtype rules as sqrt_promoted.

fn expm1_promoted #

fn expm1_promoted[R, T](t &Tensor[T]) !&Tensor[R]

expm1_promoted computes exp(x)-1 accurately near zero using the same output dtype rules as sqrt_promoted.

fn exponential #

fn exponential[T](lambda f64, shape []int, params TensorData) &Tensor[T]

exponential returns a tensor of exponential random variables.

fn eye #

fn eye[T](m int, n int, k int, params TensorData) &Tensor[T]

eye returns a 2D array with ones on the diagonal and zeros elsewhere

fn f_distribution #

fn f_distribution(numerator_df f64, denominator_df f64, shape []int, params TensorData) !&Tensor[f64]

f_distribution returns samples from the F distribution using VTL's global random stream.

fn float_power_promoted #

fn float_power_promoted[T, U](a &Tensor[T], b &Tensor[U]) !&Tensor[f64]

float_power_promoted computes elementwise powers as float64 for real numeric or boolean inputs, allowing negative integer exponents like NumPy.

fn float_power_scalar_left_promoted #

fn float_power_scalar_left_promoted[T, U](scalar U, a &Tensor[T]) !&Tensor[f64]

float_power_scalar_left_promoted raises a weak real numeric or boolean scalar to tensor values and always returns float64.

fn float_power_scalar_promoted #

fn float_power_scalar_promoted[T, U](a &Tensor[T], scalar U) !&Tensor[f64]

float_power_scalar_promoted raises tensor values to a weak real numeric or boolean scalar and always returns float64.

fn floor_divide_promoted #

fn floor_divide_promoted[R, T, U](a &Tensor[T], b &Tensor[U]) !&Tensor[R]

floor_divide_promoted performs NumPy-style floor division after promoting real numeric tensor operands to R. Complex inputs are unsupported.

fn floor_divide_scalar_left_promoted #

fn floor_divide_scalar_left_promoted[R, T, U](scalar U, a &Tensor[T]) !&Tensor[R]

floor_divide_scalar_left_promoted performs NumPy-style floor division with a weak real numeric scalar as the numerator using the inferred dtype R.

fn floor_divide_scalar_promoted #

fn floor_divide_scalar_promoted[R, T, U](a &Tensor[T], scalar U) !&Tensor[R]

floor_divide_scalar_promoted performs NumPy-style floor division by a weak real numeric scalar using the inferred promoted dtype R.

fn floor_promoted #

fn floor_promoted[R, T](t &Tensor[T]) !&Tensor[R]

floor_promoted returns elementwise floors while preserving the input dtype.

fn fmax_promoted #

fn fmax_promoted[R, T, U](a &Tensor[T], b &Tensor[U]) !&Tensor[R]

fmax_promoted returns the broadcasted maximum while ignoring one NaN operand. The output dtype follows NumPy-style promotion.

fn fmax_scalar_left_promoted #

fn fmax_scalar_left_promoted[R, T, U](scalar U, a &Tensor[T]) !&Tensor[R]

fmax_scalar_left_promoted ignores a single NaN operand with the scalar on the left.

fn fmax_scalar_promoted #

fn fmax_scalar_promoted[R, T, U](a &Tensor[T], scalar U) !&Tensor[R]

fmax_scalar_promoted ignores a single NaN operand, like numpy.fmax.

fn fmin_promoted #

fn fmin_promoted[R, T, U](a &Tensor[T], b &Tensor[U]) !&Tensor[R]

fmin_promoted returns the broadcasted minimum while ignoring one NaN operand. The output dtype follows NumPy-style promotion.

fn fmin_scalar_left_promoted #

fn fmin_scalar_left_promoted[R, T, U](scalar U, a &Tensor[T]) !&Tensor[R]

fmin_scalar_left_promoted ignores a single NaN operand with the scalar on the left.

fn fmin_scalar_promoted #

fn fmin_scalar_promoted[R, T, U](a &Tensor[T], scalar U) !&Tensor[R]

fmin_scalar_promoted ignores a single NaN operand, like numpy.fmin.

fn fmod_promoted #

fn fmod_promoted[R, T, U](a &Tensor[T], b &Tensor[U]) !&Tensor[R]

fmod_promoted returns the remainder with the sign of the dividend after NumPy-style dtype promotion and broadcasting. Boolean and complex inputs are unsupported; R must match promote_types(dtype_ofT, dtype_ofU).

fn fmod_scalar_left_promoted #

fn fmod_scalar_left_promoted[R, T, U](scalar U, a &Tensor[T]) !&Tensor[R]

fmod_scalar_left_promoted applies fmod with a weak real numeric scalar as the dividend.

fn fmod_scalar_promoted #

fn fmod_scalar_promoted[R, T, U](a &Tensor[T], scalar U) !&Tensor[R]

fmod_scalar_promoted applies fmod with a weak real numeric scalar.

fn frexp_promoted #

fn frexp_promoted[R, T](t &Tensor[T]) !(&Tensor[R], &Tensor[int])

frexp_promoted decomposes real numeric or boolean values into a floating mantissa and an integer base-2 exponent. f32 inputs preserve f32 mantissas; all other supported inputs produce f64 mantissas.

fn from_1d #

fn from_1d[T](arr []T, params TensorData) !&Tensor[T]

from_1d takes a one dimensional array of floating point values and returns a one dimensional Tensor if possible

fn from_2d #

@[direct_array_access]
fn from_2d[T](a [][]T, params TensorData) !&Tensor[T]

from_2d exposes this operation as part of the public API.

fn from_array #

fn from_array[T](arr []T, shape []int, params TensorData) !&Tensor[T]

from_array takes a one-dimensional array of T values and coerces it into an arbitrary shape. It returns an error when the shape does not fit the values. Values are interpreted in the selected memory order.

fn from_borrowed #

fn from_borrowed[T](data []T, shape []int, strides []int, offset int, mutable bool) !&Tensor[T]

from_borrowed validates a strided CPU buffer and wraps it in a zero-copy tensor. The caller must keep the backing array alive and must not mutate it while the tensor is in use. For a copy, build a view with storage.borrow or storage.contiguous and call its to_tensor method.

fn full #

@[inline]
fn full[T](shape []int, val T, params TensorData) &Tensor[T]

full exposes this operation as part of the public API.

fn full_index #

fn full_index() TensorIndex

full_index selects every position on one axis.

fn full_like #

fn full_like[T](t &Tensor[T], val T) &Tensor[T]

full_like returns a new tensor of the same shape and type as a given Tensor filled with a given val

fn full_on #

fn full_on[T](shape []int, value T, options CreationOptions) !&Tensor[T]

full_on creates a filled tensor after validating its creation options.

fn fused_scalar_chain #

fn fused_scalar_chain[T](input &Tensor[T], ops []FusedScalarOp, scalars []f64) !&Tensor[T]

fused_scalar_chain applies scalar operations in order using one output buffer. The eager promoted helpers allocate a result (and a scalar tensor) for every operation; this kernel allocates once and mutates the buffer in place while keeping each operation and each scalar conversion, so the result is bit-for-bit the same as the equivalent eager chain.

fn gamma #

fn gamma(alpha f64, scale f64, shape []int, params TensorData) !&Tensor[f64]

gamma returns samples from a Gamma distribution on VTL's global random stream. alpha is the shape and scale is the scale parameter.

fn geometric #

fn geometric(probability f64, shape []int, params TensorData) !&Tensor[int]

geometric returns the number of Bernoulli trials needed for the first success, sampled from V's global random stream. Results start at 1.

fn gumbel #

fn gumbel(location f64, scale f64, shape []int, params TensorData) !&Tensor[f64]

gumbel returns samples from a Gumbel distribution using VTL's global stream.

fn heaviside_promoted #

fn heaviside_promoted[R, T, U](x1 &Tensor[T], x2 &Tensor[U]) !&Tensor[R]

heaviside_promoted returns 0 for negative x1, 1 for positive x1, and x2 for zero x1, using NumPy-style float output promotion.

fn hermite #

fn hermite(coefficients []f64, domain [2]f64, window [2]f64) !Hermite

hermite constructs a physicists' Hermite series from ascending coefficients and domain/window bounds.

fn hermite_e #

fn hermite_e(coefficients []f64, domain [2]f64, window [2]f64) !HermiteE

hermite_e constructs a probabilists' HermiteE series from ascending coefficients and domain/window bounds.

fn hermite_e_fit #

fn hermite_e_fit(x []f64, y []f64, degree int, domain [2]f64, window [2]f64) !HermiteE

hermite_e_fit computes a least-squares probabilists' HermiteE fit of the given degree over domain and window.

fn hermite_e_from_polynomial #

fn hermite_e_from_polynomial(p Polynomial, domain [2]f64, window [2]f64) !HermiteE

hermite_e_from_polynomial converts a power-series Polynomial into the probabilists' HermiteE basis on domain and window.

fn hermite_fit #

fn hermite_fit(x []f64, y []f64, degree int, domain [2]f64, window [2]f64) !Hermite

hermite_fit computes a least-squares physicists' Hermite fit of the given degree over domain and window.

fn hermite_from_polynomial #

fn hermite_from_polynomial(p Polynomial, domain [2]f64, window [2]f64) !Hermite

hermite_from_polynomial converts a power-series Polynomial into the physicists' Hermite basis on domain and window.

fn hstack #

fn hstack[T](ts []&Tensor[T]) !&Tensor[T]

hstack stacks arrays in sequence horizontally (column wise)

fn hypergeometric #

fn hypergeometric(ngood int, nbad int, nsample int, shape []int, params TensorData) !&Tensor[int]

hypergeometric returns the number of good items in draws made without replacement from a population containing ngood good and nbad bad items.

fn hypot_promoted #

fn hypot_promoted[R, T, U](a &Tensor[T], b &Tensor[U]) !&Tensor[R]

hypot_promoted computes elementwise hypotenuses with NumPy-style float output promotion and broadcasting.

fn identity #

@[inline]
fn identity[T](n int, params TensorData) &Tensor[T]

identity exposes this operation as part of the public API.

fn imag #

fn imag(input &Tensor[complex.Complex]) !&Tensor[f64]

imag returns the imaginary components of a complex tensor as a float64 tensor.

fn indices #

fn indices(dimensions []int, params TensorData) !&Tensor[int]

indices returns a dense coordinate tensor with shape [dimensions.len, ...dimensions], matching numpy.indices for integer arrays. Each leading-axis plane contains the coordinates for one input dimension.

fn indices_sparse #

fn indices_sparse(dimensions []int, params TensorData) ![]&Tensor[int]

indices_sparse returns one broadcastable coordinate tensor per dimension. Each result has rank dimensions.len and only its own axis has non-unit length, matching numpy.indices(..., sparse: true) without allocating the dense coordinate stack.

fn integer_index #

fn integer_index(index int) TensorIndex

integer_index selects one position and removes its axis from the result.

fn isin #

fn isin[T](elements &Tensor[T], test_elements &Tensor[T]) &Tensor[bool]

isin returns a boolean tensor indicating whether each element occurs in test_elements. It preserves the shape and logical iteration order of the input, including for non-contiguous views.

fn kron #

fn kron[T](a &Tensor[T], b &Tensor[T]) !&Tensor[T]

kron returns the Kronecker product of two tensors. The lower-rank input is left-padded with singleton dimensions, matching NumPy's rank semantics.

fn laplace #

fn laplace(location f64, scale f64, shape []int, params TensorData) !&Tensor[f64]

laplace returns samples from a Laplace distribution using VTL's global stream.

fn ldexp #

fn ldexp[T](mantissa &Tensor[T], exponent &Tensor[int]) !&Tensor[T]

ldexp scales each floating-point mantissa by 2 raised to the corresponding integer exponent. The operands broadcast to a common shape.

fn ldexp_promoted #

fn ldexp_promoted[R, T, U](mantissa &Tensor[T], exponent &Tensor[U]) !&Tensor[R]

ldexp_promoted applies NumPy-style dtype selection to real mantissas and integer exponents. Floating mantissas preserve f32/f64; integer and boolean mantissas produce f64.

fn ldexp_scalar #

fn ldexp_scalar[T](mantissa &Tensor[T], exponent int) !&Tensor[T]

ldexp_scalar scales a floating-point mantissa tensor by one integer exponent.

fn ldexp_scalar_left #

fn ldexp_scalar_left[T](mantissa T, exponent &Tensor[int]) !&Tensor[T]

ldexp_scalar_left scales one floating-point mantissa by an exponent tensor.

fn legendre #

fn legendre(coefficients []f64, domain [2]f64, window [2]f64) !Legendre

legendre constructs a Legendre series from ascending coefficients and domain/window bounds.

fn legendre_fit #

fn legendre_fit(x []f64, y []f64, degree int, domain [2]f64, window [2]f64) !Legendre

legendre_fit computes a least-squares Legendre fit of the given degree over domain and window.

fn legendre_from_polynomial #

fn legendre_from_polynomial(p Polynomial, domain [2]f64, window [2]f64) !Legendre

legendre_from_polynomial converts a power-series Polynomial into the Legendre basis on domain and window.

fn linspace #

fn linspace[T](start f64, stop f64, num int, params LinspaceData) !&Tensor[T]

linspace returns num evenly spaced values between start and stop. The endpoint is included by default; set endpoint: false to exclude stop.

fn log #

fn log(input &Tensor[complex.Complex]) !&Tensor[complex.Complex]

log applies the principal complex natural logarithm to every element.

fn log10_promoted #

fn log10_promoted[R, T](t &Tensor[T]) !&Tensor[R]

log10_promoted computes elementwise base-ten logarithms using the same output dtype rules as sqrt_promoted.

fn log1p_promoted #

fn log1p_promoted[R, T](t &Tensor[T]) !&Tensor[R]

log1p_promoted computes log(1+x) accurately near zero using the same output dtype rules as sqrt_promoted.

fn log2_promoted #

fn log2_promoted[R, T](t &Tensor[T]) !&Tensor[R]

log2_promoted computes elementwise base-two logarithms using the same output dtype rules as sqrt_promoted.

fn log_promoted #

fn log_promoted[R, T](t &Tensor[T]) !&Tensor[R]

log_promoted computes elementwise natural logarithms using the same output dtype rules as sqrt_promoted.

fn logaddexp #

fn logaddexp[T](a &Tensor[T], b &Tensor[T]) !&Tensor[T]

logaddexp computes log(exp(a) + exp(b)) elementwise using a stable form. The f32/f64 operands broadcast to a common output shape.

fn logaddexp2 #

fn logaddexp2[T](a &Tensor[T], b &Tensor[T]) !&Tensor[T]

logaddexp2 computes log2(2^a + 2^b) elementwise using a stable form. The f32/f64 operands broadcast to a common output shape.

fn logaddexp2_promoted #

fn logaddexp2_promoted[R, T, U](a &Tensor[T], b &Tensor[U]) !&Tensor[R]

logaddexp2_promoted computes log2(2^a+2^b) stably with NumPy-style floating output promotion and broadcasting.

fn logaddexp_promoted #

fn logaddexp_promoted[R, T, U](a &Tensor[T], b &Tensor[U]) !&Tensor[R]

logaddexp_promoted computes log(exp(a)+exp(b)) stably with NumPy-style floating output promotion and broadcasting.

fn logaddexp_scalar #

fn logaddexp_scalar[T](tensor &Tensor[T], scalar T) !&Tensor[T]

logaddexp_scalar computes log(exp(x) + exp(scalar)) elementwise with a stable form, preserving the tensor's shape and f32/f64 dtype.

fn logaddexp_scalar_left #

fn logaddexp_scalar_left[T](scalar T, tensor &Tensor[T]) !&Tensor[T]

logaddexp_scalar_left computes log(exp(scalar) + exp(x)) elementwise with a stable form, preserving the tensor's shape and f32/f64 dtype.

fn logistic #

fn logistic(location f64, scale f64, shape []int, params TensorData) !&Tensor[f64]

logistic returns samples from a Logistic distribution using VTL's global stream.

fn lognormal #

fn lognormal(mean f64, sigma f64, shape []int, params TensorData) !&Tensor[f64]

lognormal returns samples whose natural logarithm follows a normal distribution using VTL's global random stream.

fn logseries #

fn logseries(probability f64, shape []int, params TensorData) !&Tensor[int]

logseries samples positive integers from a logarithmic-series distribution using VTL's global random stream.

fn logspace #

fn logspace[T](start f64, stop f64, num int, params LogspaceData) !&Tensor[T]

logspace returns num values spaced evenly on a logarithmic scale between base^start and base^stop. The endpoint is included by default.

fn masked_array #

fn masked_array[T](values &Tensor[T], mask &Tensor[bool]) !MaskedArray[T]

masked_array creates a masked tensor. The mask broadcasts against values; the returned values and mask are views with the common broadcast shape.

fn maximum_promoted #

fn maximum_promoted[R, T, U](a &Tensor[T], b &Tensor[U]) !&Tensor[R]

maximum_promoted returns the broadcasted maximum after NumPy-style dtype promotion. NaNs propagate, and equal values follow NumPy's operand ordering.

fn maximum_scalar_left_promoted #

fn maximum_scalar_left_promoted[R, T, U](scalar U, a &Tensor[T]) !&Tensor[R]

maximum_scalar_left_promoted applies maximum with the scalar as the left operand, preserving operand order for ties and NaNs.

fn maximum_scalar_promoted #

fn maximum_scalar_promoted[R, T, U](a &Tensor[T], scalar U) !&Tensor[R]

maximum_scalar_promoted applies NumPy-style maximum to a tensor and weak scalar. R must match the inferred weak-scalar result dtype.

fn meshgrid #

fn meshgrid[T](x &Tensor[T], y &Tensor[T], params TensorData) !(&Tensor[T], &Tensor[T])

meshgrid builds dense two-dimensional XY coordinate grids from two vectors. The output shape is [len(y), len(x)], matching NumPy's default indexing="xy".

fn meshgrid_n #

fn meshgrid_n[T](vectors []&Tensor[T], indexing MeshgridIndexing, params TensorData) ![]&Tensor[T]

meshgrid_n builds one dense coordinate tensor for each one-dimensional input. With xy, the first two dimensions are swapped, matching NumPy's default indexing convention. ij preserves the input axis order.

fn minimum_promoted #

fn minimum_promoted[R, T, U](a &Tensor[T], b &Tensor[U]) !&Tensor[R]

minimum_promoted returns the broadcasted minimum after NumPy-style dtype promotion. NaNs propagate, and equal values follow NumPy's operand ordering.

fn minimum_scalar_left_promoted #

fn minimum_scalar_left_promoted[R, T, U](scalar U, a &Tensor[T]) !&Tensor[R]

minimum_scalar_left_promoted applies minimum with the scalar as the left operand, preserving operand order for ties and NaNs.

fn minimum_scalar_promoted #

fn minimum_scalar_promoted[R, T, U](a &Tensor[T], scalar U) !&Tensor[R]

minimum_scalar_promoted applies NumPy-style minimum to a tensor and weak scalar. R must match the inferred weak-scalar result dtype.

fn mixed_index #

fn mixed_index[T](t &Tensor[T], indices []TensorIndex) !&Tensor[T]

mixed_index combines full slices, ranges, scalar integers, broadcasted coordinate tensors, ellipsis, and inserted size-one axes. Omitted trailing axes select the full axis. If every index is basic, the result is a view; if any coordinate tensor is used, the result is an independent row-major copy.

fn modf_promoted #

fn modf_promoted[R, T](t &Tensor[T]) !(&Tensor[R], &Tensor[R])

modf_promoted returns fractional and integral parts for real numeric or boolean values. f32 inputs preserve f32 outputs; all other inputs produce f64 outputs.

fn multiply_promoted #

fn multiply_promoted[R, T, U](a &Tensor[T], b &Tensor[U]) !&Tensor[R]

multiply_promoted multiplies real numeric or boolean tensors after converting both operands to the explicitly selected NumPy-style result dtype.

fn multiply_scalar_left_promoted #

fn multiply_scalar_left_promoted[R, T, U](scalar U, a &Tensor[T]) !&Tensor[R]

multiply_scalar_left_promoted multiplies a tensor by a weak scalar using NumPy-style promotion.

fn multiply_scalar_promoted #

fn multiply_scalar_promoted[R, T, U](a &Tensor[T], scalar U) !&Tensor[R]

multiply_scalar_promoted multiplies by a weak numeric scalar using NumPy-style promotion. R must be the inferred result dtype.

fn multivariate_hypergeometric #

fn multivariate_hypergeometric(colors &Tensor[int], nsample int, sample_shape []int, params TensorData) !&Tensor[int]

multivariate_hypergeometric samples category counts from VTL's global RNG. The final output axis has one count per entry in colors.

fn multivariate_normal #

fn multivariate_normal(mean &Tensor[f64], covariance &Tensor[f64], sample_shape []int, params TensorData) !&Tensor[f64]

multivariate_normal draws samples with the requested mean and covariance using VTL's global random stream.

fn negative_binomial #

fn negative_binomial(n f64, probability f64, shape []int, params TensorData) !&Tensor[int]

negative_binomial counts failures before n successes on VTL's global random stream. n may be any finite positive real value.

fn new_random_generator #

fn new_random_generator(seed int) RandomGenerator

new_random_generator creates an independent generator initialized from seed.

fn new_random_generator_from_state #

fn new_random_generator_from_state(state RandomGeneratorState) !RandomGenerator

new_random_generator_from_state restores an independent generator snapshot.

fn newaxis_index #

fn newaxis_index() TensorIndex

newaxis_index inserts a size-one axis at this position without consuming an input axis. Basic indexing with a new axis remains a view.

fn nextafter_promoted #

fn nextafter_promoted[R, T, U](x &Tensor[T], y &Tensor[U]) !&Tensor[R]

nextafter_promoted steps one representable output value from x toward y. The f32 path uses f32 nextafter semantics instead of rounding an f64 step.

fn noncentral_chi_square #

fn noncentral_chi_square(degrees_of_freedom f64, noncentrality f64, shape []int, params TensorData) !&Tensor[f64]

noncentral_chi_square returns samples from a noncentral chi-square distribution using VTL's global random stream.

fn noncentral_f #

fn noncentral_f(numerator_df f64, denominator_df f64, noncentrality f64, shape []int, params TensorData) !&Tensor[f64]

noncentral_f returns samples from a noncentral F distribution using VTL's global random stream.

fn nonzero #

fn nonzero[T](t &Tensor[T]) ![]&Tensor[int]

nonzero returns one index tensor per input axis, matching NumPy's tuple of coordinate arrays. A nonzero scalar is treated as a one-dimensional value with index zero, following NumPy's scalar promotion behavior.

fn normal #

fn normal[T](shape []int, params NormalTensorData) &Tensor[T]

normal returns a tensor of normal random variables.

fn one_hot #

fn one_hot(indices &Tensor[int], num_classes int, params TensorData) !&Tensor[int]

one_hot encodes integer class indices as rows of a one-hot matrix. The output shape is indices.shape followed by num_classes; every index must be in [0, num_classes). An empty index tensor returns an empty tensor with the corresponding trailing class dimension.

fn ones #

@[inline]
fn ones[T](shape []int, params TensorData) &Tensor[T]

ones exposes this operation as part of the public API.

fn ones_like #

@[inline]
fn ones_like[T](t &Tensor[T]) &Tensor[T]

ones_like exposes this operation as part of the public API.

fn ones_on #

fn ones_on[T](shape []int, options CreationOptions) !&Tensor[T]

ones_on creates a one-filled tensor after validating its creation options.

fn pad #

fn pad[T](t &Tensor[T], pad_width [][]int, mode PadMode, constant_value T) !&Tensor[T]

pad adds a before/after width to every dimension. pad_width contains one [before, after] pair per axis. Reflect excludes the edge value; symmetric includes it. constant_value is used only with .constant.

fn pareto #

fn pareto(shape_parameter f64, shape []int, params TensorData) !&Tensor[f64]

pareto returns standard Pareto samples (minimum zero) using VTL's global stream.

fn parse_device #

fn parse_device(text string) !DeviceRef

parse_device decodes a device string such as cpu, cuda, or vulkan:1.

fn partition #

fn partition[T](t &Tensor[T], kth int) !&Tensor[T]

partition returns a copy with the value at kth in its sorted position and every preceding value less than or equal to it. Remaining values are unspecified, matching NumPy's default last-axis behavior.

fn partition_axis #

fn partition_axis[T](t &Tensor[T], kths []int, axis int) !&Tensor[T]

partition_axis partially sorts each one-dimensional slice along axis. kth positions are local to each slice; multiple positions can be requested in one pass without fully sorting the data.

fn poisson #

fn poisson(lambda f64, shape []int, params TensorData) !&Tensor[int]

poisson returns integer event counts from VTL's global random stream.

fn polynomial #

fn polynomial(coefficients []f64) !Polynomial

polynomial constructs a power-series Polynomial from ascending coefficients, trimming trailing zeros.

fn polynomial_fit #

fn polynomial_fit(x []f64, y []f64, degree int) !Polynomial

polynomial_fit computes a least-squares power-series fit with a scaled Vandermonde matrix and Householder QR.

fn pow_promoted #

fn pow_promoted[R, T, U](a &Tensor[T], b &Tensor[U]) !&Tensor[R]

pow_promoted computes elementwise powers after broadcasting. Numeric pairs use promote_types(dtype_ofT, dtype_ofU); boolean pairs return int8, matching NumPy. Integer powers keep exact-width wrapping arithmetic and reject negative integer exponents. Complex pairs use the principal branch; 64-bit integers cannot be combined with a floating output because conversion could lose integer precision.

fn pow_scalar_left_promoted #

fn pow_scalar_left_promoted[R, T, U](scalar U, a &Tensor[T]) !&Tensor[R]

pow_scalar_left_promoted raises a weak numeric or complex scalar to each tensor value using NumPy-style promotion. R must match the inferred output dtype; negative integer exponents are rejected.

fn pow_scalar_promoted #

fn pow_scalar_promoted[R, T, U](a &Tensor[T], scalar U) !&Tensor[R]

pow_scalar_promoted raises each tensor value to a weak numeric or complex scalar exponent using NumPy-style promotion. R must match the inferred output dtype; negative integer exponents are rejected.

fn power #

fn power(shape_parameter f64, shape []int, params TensorData) !&Tensor[f64]

power returns samples from NumPy's power distribution on [0, 1] using VTL's global stream.

fn promote_types #

fn promote_types(a DType, b DType) !DType

promote_types returns the common dtype for two array dtypes. Its numeric rules are modeled on NumPy, using the integer and floating-point types VTL currently supports. If VTL has no signed integer width that can represent both inputs, it promotes to float64. Mixing strings with other dtypes is rejected; scalar-value weak promotion is not part of this dtype-only API.

fn radians_promoted #

fn radians_promoted[R, T](t &Tensor[T]) !&Tensor[R]

radians_promoted converts degrees to radians with NumPy-style float output promotion.

fn random #

fn random[T](min T, max T, shape []int, params TensorData) &Tensor[T]

random returns a new Tensor of given shape and type, initialized with random numbers between a given min and max value

fn random_generator_state_from_json #

fn random_generator_state_from_json(value string) !RandomGeneratorState

random_generator_state_from_json parses and validates a serialized snapshot.

fn random_seed #

fn random_seed(i int)

random_seed resets VTL's global random generator for reproducible results. The seed affects random tensor constructors and model parameter initialization that use V's default random generator.

fn range #

fn range[T](from int, to int, params TensorData) &Tensor[T]

range returns values in [from, to), or an empty tensor when to <= from.

fn ravel_multi_index #

@[direct_array_access]
fn ravel_multi_index(coordinates []&Tensor[int], dimensions []int,
	options MultiIndexOptions) !&Tensor[int]

ravel_multi_index converts one integer coordinate tensor per dimension to flat indices. Coordinate tensors broadcast together. The result shape is their broadcast shape. mode applies raise, wrap, or clip bounds handling to every axis; axis_modes may instead specify one mode per axis. Order selects C (row-major) or F (column-major) flattening.

fn rayleigh #

fn rayleigh(scale f64, shape []int, params TensorData) !&Tensor[f64]

rayleigh returns samples from a Rayleigh distribution using VTL's global stream.

fn real #

fn real(input &Tensor[complex.Complex]) !&Tensor[f64]

real returns the real components of a complex tensor as a float64 tensor.

fn remainder_promoted #

fn remainder_promoted[R, T, U](a &Tensor[T], b &Tensor[U]) !&Tensor[R]

remainder_promoted returns the element-wise NumPy remainder of real numeric tensors after dtype promotion and broadcasting. Complex inputs are rejected. Integer zero divisors produce zero; floating-point zero divisors produce NaN.

fn remainder_scalar_left_promoted #

fn remainder_scalar_left_promoted[R, T, U](scalar U, a &Tensor[T]) !&Tensor[R]

remainder_scalar_left_promoted returns the NumPy-style remainder of a weak scalar and tensor. Complex operands are unsupported.

fn remainder_scalar_promoted #

fn remainder_scalar_promoted[R, T, U](a &Tensor[T], scalar U) !&Tensor[R]

remainder_scalar_promoted returns the NumPy-style remainder of a tensor and weak numeric scalar. Complex operands are unsupported; R must be the inferred result dtype.

fn repeat #

fn repeat[T](t &Tensor[T], repeats int) !&Tensor[T]

repeat returns a copy with each value repeated the requested number of times. If axis is omitted the tensor is flattened first, matching NumPy.

fn repeat_axis #

fn repeat_axis[T](t &Tensor[T], repeats int, axis int) !&Tensor[T]

repeat_axis repeats each value along axis and preserves the other dimensions.

fn rint_promoted #

fn rint_promoted[R, T](t &Tensor[T]) !&Tensor[R]

rint_promoted rounds elementwise to the nearest integer using ties-to-even and the floating output dtype rules of sqrt_promoted.

fn roll #

fn roll[T](t &Tensor[T], shift int, axes ...int) !&Tensor[T]

roll shifts values along the flattened tensor when axes is omitted. When axes are provided, the same shift is applied independently to each axis. Negative axes and shifts are accepted. The result is always a copy.

fn roll_axes #

fn roll_axes[T](t &Tensor[T], shift int, axes []int) !&Tensor[T]

roll_axes applies one scalar shift to each selected axis. Repeated axes accumulate their shifts, and an empty axis list leaves the tensor unchanged.

fn roll_flat #

fn roll_flat[T](t &Tensor[T], shift int) !&Tensor[T]

roll_flat circularly shifts the row-major logical values and preserves the original shape.

fn roll_shifts #

fn roll_shifts[T](t &Tensor[T], shifts []int, axes []int) !&Tensor[T]

roll_shifts applies paired shifts and axes, accumulating repeated axes.

fn rot90 #

fn rot90[T](t &Tensor[T]) !&Tensor[T]

rot90 rotates a tensor counterclockwise by k quarter-turns in its first two dimensions, matching NumPy's default axes=(0, 1).

fn rot90_axes #

fn rot90_axes[T](t &Tensor[T], k int, axes []int) !&Tensor[T]

rot90_axes rotates counterclockwise in the plane defined by two distinct axes.

fn rot90_k #

fn rot90_k[T](t &Tensor[T], k int) !&Tensor[T]

rot90_k rotates in the first two dimensions by k counterclockwise quarter-turns.

fn scalar_left_promoted_auto #

fn scalar_left_promoted_auto[T, U](scalar U, a &Tensor[T], operation PromotedArithmetic) !PromotedTensor

scalar_left_promoted_auto selects the NumPy-style result dtype for a weak scalar on the left, preserving noncommutative operation order.

fn scalar_promoted_auto #

fn scalar_promoted_auto[T, U](a &Tensor[T], scalar U, operation PromotedArithmetic) !PromotedTensor

scalar_promoted_auto selects the NumPy-style result dtype for a weak scalar on the right, without requiring the caller to provide the output type.

fn searchsorted #

fn searchsorted[T](sorted &Tensor[T], values &Tensor[T], side SearchSide) !&Tensor[int]

searchsorted returns insertion positions for values in an ascending 1-D tensor. The input is assumed to be sorted; each query uses binary search.

fn searchsorted_descending #

fn searchsorted_descending[T](sorted &Tensor[T], values &Tensor[T], side SearchSide) !&Tensor[int]

searchsorted_descending returns insertion positions for values in a descending 1-D tensor. The input is assumed to be sorted; each query uses binary search. The output has the same shape as values.

fn select #

fn select[T](conditions []&Tensor[bool], choices []&Tensor[T], default T) !&Tensor[T]

select picks the value from the first choice whose condition is true at each output position. Conditions and choices broadcast to a common shape; default is used where no condition is true.

fn seq #

@[inline]
fn seq[T](n int, params TensorData) &Tensor[T]

seq exposes this operation as part of the public API.

fn sin #

fn sin(input &Tensor[complex.Complex]) !&Tensor[complex.Complex]

sin applies the complex sine to every element.

fn sin_promoted #

fn sin_promoted[R, T](t &Tensor[T]) !&Tensor[R]

sin_promoted computes elementwise sine values using the same output dtype rules as sqrt_promoted.

fn sinh #

fn sinh(input &Tensor[complex.Complex]) !&Tensor[complex.Complex]

sinh applies the complex hyperbolic sine to every element.

fn sinh_promoted #

fn sinh_promoted[R, T](t &Tensor[T]) !&Tensor[R]

sinh_promoted computes elementwise hyperbolic sine values using the same output dtype rules as sqrt_promoted.

fn slice_all #

fn slice_all(step int) !TensorIndex

slice_all selects the whole axis, optionally traversing it in reverse.

fn slice_from #

fn slice_from(start int, step int) !TensorIndex

slice_from selects from start through the end of the axis in step increments. A negative step traverses toward the beginning.

fn slice_index #

fn slice_index(start int, stop int, step int) !TensorIndex

slice_index selects an explicit Python-style [start:stop:step] range. Negative boundaries count from the end; a zero step is rejected.

fn slice_to #

fn slice_to(stop int, step int) !TensorIndex

slice_to selects from the beginning of the axis through stop in step increments.

fn sort #

fn sort[T](t &Tensor[T]) !&Tensor[T]

sort returns a copy sorted along the last axis, matching NumPy's default.

fn sort_axis #

fn sort_axis[T](t &Tensor[T], axis int) !&Tensor[T]

sort_axis returns a copy sorted in ascending order along axis. Floating-point NaNs sort after all non-NaN values, and equal values keep their input order.

fn sqrt #

fn sqrt(input &Tensor[complex.Complex]) !&Tensor[complex.Complex]

sqrt applies the principal complex square root to every element.

fn sqrt_promoted #

fn sqrt_promoted[R, T](t &Tensor[T]) !&Tensor[R]

sqrt_promoted computes elementwise square roots for real numeric or boolean tensors. It returns float64 for float64 and >=32-bit integer inputs, and float32 otherwise; NumPy float16 results are widened because VTL does not support float16.

fn stack #

fn stack[T](ts []&Tensor[T], data AxisData) !&Tensor[T]

stack join a sequence of arrays along a new axis.

fn student_t #

fn student_t(degrees_of_freedom f64, shape []int, params TensorData) !&Tensor[f64]

student_t returns samples from the standard Student's t distribution using VTL's global random stream.

fn subtract_promoted #

fn subtract_promoted[R, T, U](a &Tensor[T], b &Tensor[U]) !&Tensor[R]

subtract_promoted subtracts real numeric or boolean tensors after converting both operands to the explicitly selected NumPy-style result dtype. Boolean subtraction is unsupported.

fn subtract_scalar_left_promoted #

fn subtract_scalar_left_promoted[R, T, U](scalar U, a &Tensor[T]) !&Tensor[R]

subtract_scalar_left_promoted subtracts a tensor from a weak scalar using NumPy-style promotion.

fn subtract_scalar_promoted #

fn subtract_scalar_promoted[R, T, U](a &Tensor[T], scalar U) !&Tensor[R]

subtract_scalar_promoted subtracts a weak numeric scalar using NumPy-style promotion. R must be the inferred result dtype.

fn tan #

fn tan(input &Tensor[complex.Complex]) !&Tensor[complex.Complex]

tan applies the complex tangent to every element.

fn tan_promoted #

fn tan_promoted[R, T](t &Tensor[T]) !&Tensor[R]

tan_promoted computes elementwise tangent values using the same output dtype rules as sqrt_promoted.

fn tanh #

fn tanh(input &Tensor[complex.Complex]) !&Tensor[complex.Complex]

tanh applies the complex hyperbolic tangent to every element.

fn tanh_promoted #

fn tanh_promoted[R, T](t &Tensor[T]) !&Tensor[R]

tanh_promoted computes elementwise hyperbolic tangent values using the same output dtype rules as sqrt_promoted.

fn td #

fn td[T](x T) TensorDataType

td exposes this operation as part of the public API.

fn tensor #

fn tensor[T](init T, shape []int, params TensorData) &Tensor[T]

tensor allocates a Tensor filled with the given value and shape.

fn tensor_like #

fn tensor_like[T](t &Tensor[T]) &Tensor[T]

tensor_like returns a new tensor created with similar storage properties as the Tensor t

fn tensor_like_with_shape #

fn tensor_like_with_shape[T](t &Tensor[T], shape []int) &Tensor[T]

tensor_like_with_shape returns a new tensor created with similar storage properties as the Tensor t with a given shape

fn tile #

fn tile[T](t &Tensor[T], reps []int) !&Tensor[T]

tile repeats t as a block according to reps. Repetition dimensions align from the right; shorter reps are padded with ones on the left, as in NumPy.

fn triangular #

fn triangular(left f64, mode f64, right f64, shape []int, params TensorData) !&Tensor[f64]

triangular returns samples from a triangular distribution using VTL's global stream.

fn tril #

fn tril[T](input &Tensor[T], options TriangularOptions) !&Tensor[T]

tril returns a copy with entries above the k-th diagonal of each trailing matrix set to zero. Inputs must have at least two dimensions.

fn triu #

fn triu[T](input &Tensor[T], options TriangularOptions) !&Tensor[T]

triu returns a copy with entries below the k-th diagonal of each trailing matrix set to zero. Inputs must have at least two dimensions.

fn trunc_promoted #

fn trunc_promoted[R, T](t &Tensor[T]) !&Tensor[R]

trunc_promoted truncates elementwise toward zero while preserving the input dtype.

fn ufunc_accumulate #

fn ufunc_accumulate[T](input &Tensor[T], identity T, operation fn (T, T) T) !&Tensor[T]

ufunc_accumulate returns the inclusive prefix operation in logical row-major order, preserving the input shape.

fn ufunc_accumulate_axis #

fn ufunc_accumulate_axis[T](input &Tensor[T], axis int, identity T, operation fn (T, T) T) !&Tensor[T]

ufunc_accumulate_axis computes inclusive prefix reductions along one axis, preserving input shape.

fn ufunc_at #

fn ufunc_at[T](mut target &Tensor[T], indices []int, updates []T, operation fn (T, T) T) !

ufunc_at mutates flat logical positions in sequence. Repeated indices are applied repeatedly, and updates may contain one broadcast value or one value per index. Bounds are validated before the first mutation.

fn ufunc_binary #

fn ufunc_binary[T](left &Tensor[T], right &Tensor[T], operation fn (T, T) T) !&Tensor[T]

ufunc_binary applies a binary callback elementwise across broadcasted operands.

fn ufunc_binary_into #

fn ufunc_binary_into[T](left &Tensor[T], right &Tensor[T], output &Tensor[T], where_mask &Tensor[bool], has_where bool, operation fn (T, T) T) !

ufunc_binary_into applies a binary callback into a caller-owned output, preserving masked-out values.

fn ufunc_outer #

fn ufunc_outer[T](left &Tensor[T], right &Tensor[T], operation fn (T, T) T) !&Tensor[T]

ufunc_outer computes operation(left[i], right[j]) for every flattened logical pair and returns a matrix of shape [left.size, right.size].

fn ufunc_reduce #

fn ufunc_reduce[T](input &Tensor[T], identity T, operation fn (T, T) T) T

ufunc_reduce applies a binary operation in logical row-major order. The identity is returned unchanged for empty inputs.

fn ufunc_reduce_axis #

fn ufunc_reduce_axis[T](input &Tensor[T], axis int, identity T, operation fn (T, T) T) !&Tensor[T]

ufunc_reduce_axis reduces input along one axis using an explicit identity and binary operation.

fn ufunc_reduceat #

fn ufunc_reduceat[T](input &Tensor[T], indices []int, operation fn (T, T) T) !&Tensor[T]

ufunc_reduceat applies a segmented reduction in flattened logical order. Each start must be in bounds; non-increasing adjacent starts select one element, following NumPy's reduceat segment rule.

fn ufunc_unary #

fn ufunc_unary[T](input &Tensor[T], operation fn (T) T) !&Tensor[T]

ufunc_unary applies a unary callback elementwise and returns a newly allocated tensor.

fn ufunc_unary_into #

fn ufunc_unary_into[T](input &Tensor[T], output &Tensor[T], where_mask &Tensor[bool], has_where bool, operation fn (T) T) !

ufunc_unary_into preserves masked-out values in the caller-owned output.

fn unique #

fn unique[T](t &Tensor[T]) !&Tensor[T]

unique returns the sorted unique values in a flattened copy of the tensor. Floating-point NaNs are treated as one value and sort after other values.

fn unique_axis #

fn unique_axis[T](t &Tensor[T], axis int) !&Tensor[T]

unique_axis returns lexicographically sorted unique slices along axis.

fn unique_axis_result #

fn unique_axis_result[T](t &Tensor[T], axis int) !UniqueAxisResult[T]

unique_axis_result returns unique slices, occurrence counts, first source axis positions, and inverse indices aligned to the input axis.

fn unique_counts #

fn unique_counts[T](t &Tensor[T]) !UniqueCounts[T]

unique_counts returns sorted unique values and the number of occurrences of each value in the flattened input tensor.

fn unique_first_indices #

fn unique_first_indices[T](t &Tensor[T]) !&Tensor[int]

unique_first_indices returns the first flattened input index for each sorted unique value.

fn unique_inverse #

fn unique_inverse[T](t &Tensor[T]) !&Tensor[int]

unique_inverse returns the unique-value index for each flattened input element. Apply it to unique(t) to reconstruct the input values.

fn unravel_index #

@[direct_array_access]
fn unravel_index(indices &Tensor[int], dimensions []int, options UnravelIndexOptions) ![]&Tensor[int]

unravel_index converts flat indices into one coordinate tensor per axis. Each returned tensor has the same shape as indices. Order selects C (row-major) or F (column-major) decoding.

fn validate_creation_device #

fn validate_creation_device(device string) !

validate_creation_device accepts the only device available for root tensor creation. Backend tensors must be created through their backend APIs, never through a silent fallback.

fn validate_creation_options #

fn validate_creation_options[T](options CreationOptions, shape []int) !

validate_creation_options validates the device and the shape together before a validated creation call allocates storage.

fn validate_creation_shape #

fn validate_creation_shape[T](shape []int) !

validate_creation_shape rejects negative dimensions and shapes whose element count or byte size would overflow int during allocation. Zero-sized dimensions are allowed.

fn vander #

@[direct_array_access]
fn vander[T](input &Tensor[T], params VandermondeData) !&Tensor[T]

vander returns a Vandermonde matrix built from a one-dimensional input. The default column count is input.size; powers descend by default and increase when requested, matching NumPy's vander convention. T must be a numeric element type.

fn vcl_backend_available #

fn vcl_backend_available() bool

vcl_backend_available reports whether this build includes the VCL backend.

fn vcl_capabilities #

fn vcl_capabilities() []VclCapability

vcl_capabilities is the operation/DType matrix for the OpenCL backend. It is intentionally small: transfer and add_scalar are the current kernel surface; compute and network dispatch remain unimplemented.

fn vcl_ensure_supported #

fn vcl_ensure_supported(operation VclOperation, dtype DType) !

vcl_ensure_supported turns an unsupported request into an explicit error rather than silently executing on the CPU while claiming device dispatch.

fn vcl_is_supported #

fn vcl_is_supported(operation VclOperation, dtype DType) bool

vcl_is_supported answers the capability question for one operation/DType pair.

fn vcl_supported #

fn vcl_supported() []VclCapability

vcl_supported filters the matrix to operations that can run on-device.

fn vmap #

fn vmap[T](f fn (&Tensor[T]) !&Tensor[T], input &Tensor[T], in_dim int, out_dim int) !&Tensor[T]

vmap applies a tensor function independently over one input axis and stacks the results along the requested output axis. The mapped axis is removed before calling f, so f operates on one sample at a time.

fn vonmises #

fn vonmises(location f64, concentration f64, shape []int, params TensorData) !&Tensor[f64]

vonmises returns angles in [-pi, pi) from VTL's global random stream.

fn vstack #

fn vstack[T](ts []&Tensor[T]) !&Tensor[T]

vstack stack arrays in sequence vertically (row wise)

fn wald #

fn wald(mean f64, scale f64, shape []int, params TensorData) !&Tensor[f64]

wald returns samples from a Wald (inverse Gaussian) distribution using VTL's global stream.

fn weibull #

fn weibull(shape_parameter f64, shape []int, params TensorData) !&Tensor[f64]

weibull returns samples from the unit-scale Weibull distribution using VTL's global random stream.

fn where #

fn where[T](condition &Tensor[bool], x &Tensor[T], y &Tensor[T]) !&Tensor[T]

where selects elements from x or y according to condition, broadcasting all three tensors to their common shape. True condition elements select x.

fn zeros #

@[inline]
fn zeros[T](shape []int, params TensorData) &Tensor[T]

zeros exposes this operation as part of the public API.

fn zeros_like #

@[inline]
fn zeros_like[T](t &Tensor[T]) &Tensor[T]

zeros_like exposes this operation as part of the public API.

fn zeros_on #

fn zeros_on[T](shape []int, options CreationOptions) !&Tensor[T]

zeros_on creates a zero-filled tensor after validating its creation options.

fn zipf #

fn zipf(exponent f64, shape []int, params TensorData) !&Tensor[int]

zipf samples positive integers from a Zipf distribution on VTL's global RNG.

fn DType.from #

fn DType.from[W](input W) !DType

from returns the DType value of an integer or of a field name, or an error if there is none.

fn Device.from #

fn Device.from[W](input W) !Device

from returns the Device value of an integer or of a field name, or an error if there is none.

fn FusedScalarOp.from #

fn FusedScalarOp.from[W](input W) !FusedScalarOp

from returns the FusedScalarOp value of an integer or of a field name, or an error if there is none.

fn IndexKind.from #

fn IndexKind.from[W](input W) !IndexKind

from returns the IndexKind value of an integer or of a field name, or an error if there is none.

fn IteratorStrategy.from #

fn IteratorStrategy.from[W](input W) !IteratorStrategy

from returns the IteratorStrategy value of an integer or of a field name, or an error if there is none.

fn MemoryFormat.from #

fn MemoryFormat.from[W](input W) !MemoryFormat

from returns the MemoryFormat value of an integer or of a field name, or an error if there is none.

fn MeshgridIndexing.from #

fn MeshgridIndexing.from[W](input W) !MeshgridIndexing

from returns the MeshgridIndexing value of an integer or of a field name, or an error if there is none.

fn MultiIndexOrder.from #

fn MultiIndexOrder.from[W](input W) !MultiIndexOrder

from returns the MultiIndexOrder value of an integer or of a field name, or an error if there is none.

fn PadMode.from #

fn PadMode.from[W](input W) !PadMode

from returns the PadMode value of an integer or of a field name, or an error if there is none.

fn PromotedArithmetic.from #

fn PromotedArithmetic.from[W](input W) !PromotedArithmetic

from returns the PromotedArithmetic value of an integer or of a field name, or an error if there is none.

fn PutMode.from #

fn PutMode.from[W](input W) !PutMode

from returns the PutMode value of an integer or of a field name, or an error if there is none.

fn QuantileMethod.from #

fn QuantileMethod.from[W](input W) !QuantileMethod

from returns the QuantileMethod value of an integer or of a field name, or an error if there is none.

fn SearchSide.from #

fn SearchSide.from[W](input W) !SearchSide

from returns the SearchSide value of an integer or of a field name, or an error if there is none.

fn TakeMode.from #

fn TakeMode.from[W](input W) !TakeMode

from returns the TakeMode value of an integer or of a field name, or an error if there is none.

fn VclOperation.from #

fn VclOperation.from[W](input W) !VclOperation

from returns the VclOperation value of an integer or of a field name, or an error if there is none.

interface AnyTensor #

interface AnyTensor[T] {
	shape   []int
	strides []int
	cpu() &Tensor[T]
	vcl() !&Tensor[T]
	str() string
	rank() int
	size() int
	is_matrix() bool
	is_square_matrix() bool
	is_vector() bool
	is_row_major() bool
	is_col_major() bool
	is_row_major_contiguous() bool
	is_col_major_contiguous() bool
	is_contiguous() bool
mut:
	memory MemoryFormat
}

AnyTensor is an interface that allows for any tensor to be used in the vtl library

type BufferMetadata #

type BufferMetadata = storage.BufferMetadata

BufferMetadata is the ABI-friendly description of a BufferView.

type BufferView #

type BufferView[T] = storage.BufferView[T]

BufferView is a validated view over a caller-owned CPU buffer. The view and its validation live in vtl.storage; this alias keeps buffer construction discoverable from the root namespace, like numpy.frombuffer.

fn (MaskedArray[T]) filled #

fn (array &MaskedArray[T]) filled[T](fill_value T) &Tensor[T]

filled returns a row-major copy with masked entries replaced by fill_value.

fn (MaskedArray[T]) compressed #

fn (array &MaskedArray[T]) compressed[T]() !&Tensor[T]

compressed returns all unmasked values as a one-dimensional copy in row-major logical order.

fn (MaskedArray[T]) mixed_index #

fn (array &MaskedArray[T]) mixed_index[T](indices []TensorIndex) !MaskedArray[T]

mixed_index applies NumPy-style mixed basic and advanced indexing to both values and mask, preserving their alignment and view/copy behavior.

fn (MaskedArray[T]) take_along_axis #

fn (array &MaskedArray[T]) take_along_axis[T](indices &Tensor[int], axis int) !MaskedArray[T]

take_along_axis gathers matching values and mask entries using the same broadcastable index tensor.

fn (MaskedArray[T]) put_along_axis #

fn (array &MaskedArray[T]) put_along_axis[T](indices &Tensor[int], updates &MaskedArray[T], axis int) !MaskedArray[T]

put_along_axis returns a copy with masked-array updates written along axis. Update values and masks must match the index shape and are broadcast under the same shape rules as Tensor.put_along_axis.

fn (MaskedArray[T]) count #

fn (array &MaskedArray[T]) count[T]() int

count returns the number of unmasked values.

fn (MaskedArray[T]) cumsum #

fn (array &MaskedArray[T]) cumsum[T]() !MaskedArray[T]

cumsum returns the flattened cumulative sum of valid values. Masked entries stay masked in the result and do not change the running total.

fn (MaskedArray[T]) cumsum_along_axis #

fn (array &MaskedArray[T]) cumsum_along_axis[T](axis int) !MaskedArray[T]

cumsum_along_axis returns prefix sums along one axis. Masked entries remain masked and are skipped by the running total.

fn (MaskedArray[T]) cumsum_as #

fn (array &MaskedArray[T]) cumsum_as[U]() !MaskedArray[U]

cumsum_as returns the flattened cumulative sum using an explicit output accumulator type. Masked positions remain masked and are skipped.

fn (MaskedArray[T]) cumsum_along_axis_as #

fn (array &MaskedArray[T]) cumsum_along_axis_as[U](axis int) !MaskedArray[U]

cumsum_along_axis_as returns cumulative sums along one axis using an explicit output accumulator type.

fn (MaskedArray[T]) cumprod #

fn (array &MaskedArray[T]) cumprod[T]() !MaskedArray[T]

cumprod returns the flattened cumulative product of valid values. Masked entries stay masked in the result and do not change the running product.

fn (MaskedArray[T]) cumprod_along_axis #

fn (array &MaskedArray[T]) cumprod_along_axis[T](axis int) !MaskedArray[T]

cumprod_along_axis returns prefix products along one axis. Masked entries remain masked and are skipped by the running product.

fn (MaskedArray[T]) cumprod_as #

fn (array &MaskedArray[T]) cumprod_as[U]() !MaskedArray[U]

cumprod_as returns the flattened cumulative product using an explicit output accumulator type. Masked positions remain masked and are skipped.

fn (MaskedArray[T]) cumprod_along_axis_as #

fn (array &MaskedArray[T]) cumprod_along_axis_as[U](axis int) !MaskedArray[U]

cumprod_along_axis_as returns cumulative products along one axis using an explicit output accumulator type.

fn (MaskedArray[T]) add #

fn (array &MaskedArray[T]) add[T](other &MaskedArray[T]) !MaskedArray[T]

add adds two masked arrays with broadcasting and combines their masks.

fn (MaskedArray[T]) subtract #

fn (array &MaskedArray[T]) subtract[T](other &MaskedArray[T]) !MaskedArray[T]

subtract subtracts another masked array with broadcasting.

fn (MaskedArray[T]) multiply #

fn (array &MaskedArray[T]) multiply[T](other &MaskedArray[T]) !MaskedArray[T]

multiply multiplies two masked arrays with broadcasting.

fn (MaskedArray[T]) divide #

fn (array &MaskedArray[T]) divide[T](other &MaskedArray[T]) !MaskedArray[T]

divide divides by another masked array with broadcasting.

fn (MaskedArray[T]) equal #

fn (array &MaskedArray[T]) equal[T](other &MaskedArray[T]) !MaskedArray[bool]

equal performs a broadcasted equality comparison and masks invalid pairs.

fn (MaskedArray[T]) not_equal #

fn (array &MaskedArray[T]) not_equal[T](other &MaskedArray[T]) !MaskedArray[bool]

not_equal performs a broadcasted inequality comparison and masks invalid pairs.

fn (MaskedArray[T]) less_than #

fn (array &MaskedArray[T]) less_than[T](other &MaskedArray[T]) !MaskedArray[bool]

less_than compares values with < and masks invalid pairs.

fn (MaskedArray[T]) less_equal #

fn (array &MaskedArray[T]) less_equal[T](other &MaskedArray[T]) !MaskedArray[bool]

less_equal compares values with <= and masks invalid pairs.

fn (MaskedArray[T]) greater_than #

fn (array &MaskedArray[T]) greater_than[T](other &MaskedArray[T]) !MaskedArray[bool]

greater_than compares values with > and masks invalid pairs.

fn (MaskedArray[T]) greater_equal #

fn (array &MaskedArray[T]) greater_equal[T](other &MaskedArray[T]) !MaskedArray[bool]

greater_equal compares values with >= and masks invalid pairs.

fn (MaskedArray[T]) add_scalar #

fn (array &MaskedArray[T]) add_scalar[T](scalar T) !MaskedArray[T]

add_scalar adds a valid scalar to every value and preserves the mask.

fn (MaskedArray[T]) subtract_scalar #

fn (array &MaskedArray[T]) subtract_scalar[T](scalar T) !MaskedArray[T]

subtract_scalar subtracts a valid scalar from every value and preserves the mask.

fn (MaskedArray[T]) multiply_scalar #

fn (array &MaskedArray[T]) multiply_scalar[T](scalar T) !MaskedArray[T]

multiply_scalar multiplies every value by a valid scalar and preserves the mask.

fn (MaskedArray[T]) divide_scalar #

fn (array &MaskedArray[T]) divide_scalar[T](scalar T) !MaskedArray[T]

divide_scalar divides every value by a valid scalar and preserves the mask.

fn (MaskedArray[T]) sum #

fn (array &MaskedArray[T]) sum[T]() MaskedValue[T]

sum reduces all unmasked values. An entirely masked array returns a masked additive identity with value zero.

fn (MaskedArray[T]) prod #

fn (array &MaskedArray[T]) prod[T]() MaskedValue[T]

prod reduces all unmasked values. An entirely masked array returns a masked multiplicative identity with value one.

fn (MaskedArray[T]) min #

fn (array &MaskedArray[T]) min[T]() MaskedValue[T]

min returns the smallest unmasked value. An entirely masked array returns a masked result whose value is zero and must be ignored.

fn (MaskedArray[T]) max #

fn (array &MaskedArray[T]) max[T]() MaskedValue[T]

max returns the largest unmasked value. An entirely masked array returns a masked result whose value is zero and must be ignored.

fn (MaskedArray[T]) argmin #

fn (array &MaskedArray[T]) argmin[T]() MaskedValue[int]

argmin returns the flat logical index of the first smallest unmasked value. An entirely masked array returns a masked result with index zero.

fn (MaskedArray[T]) argmax #

fn (array &MaskedArray[T]) argmax[T]() MaskedValue[int]

argmax returns the flat logical index of the first largest unmasked value. An entirely masked array returns a masked result with index zero.

fn (MaskedArray[T]) argmin_along_axis #

fn (array &MaskedArray[T]) argmin_along_axis[T](axis int, keepdims bool) !MaskedArray[int]

argmin_along_axis returns the first minimum index in each axis slice. Slices with no unmasked values are marked in the output mask.

fn (MaskedArray[T]) argmax_along_axis #

fn (array &MaskedArray[T]) argmax_along_axis[T](axis int, keepdims bool) !MaskedArray[int]

argmax_along_axis returns the first maximum index in each axis slice. Slices with no unmasked values are marked in the output mask.

fn (MaskedArray[T]) mean #

fn (array &MaskedArray[T]) mean[T]() MaskedValue[f64]

mean reduces all unmasked values. An entirely masked array returns a masked NaN result.

fn (MaskedArray[T]) variance #

fn (array &MaskedArray[T]) variance[T](ddof int) !MaskedValue[f64]

variance computes population or sample variance over unmasked values. ddof is subtracted from the valid count; insufficient data returns a masked NaN.

fn (MaskedArray[T]) std #

fn (array &MaskedArray[T]) std[T](ddof int) !MaskedValue[f64]

std computes population or sample standard deviation over unmasked values.

fn (MaskedArray[T]) quantile #

fn (array &MaskedArray[T]) quantile[T](q f64) !MaskedValue[f64]

quantile computes NumPy's default linearly interpolated quantile over all unmasked values. An entirely masked or empty array returns a masked NaN.

fn (MaskedArray[T]) quantile_with_method #

fn (array &MaskedArray[T]) quantile_with_method[T](q f64, method QuantileMethod) !MaskedValue[f64]

quantile_with_method computes a selected NumPy-compatible quantile over all unmasked values. An entirely masked or empty array returns a masked NaN.

fn (MaskedArray[T]) median #

fn (array &MaskedArray[T]) median[T]() MaskedValue[f64]

median computes the median of all unmasked values.

fn (MaskedArray[T]) percentile #

fn (array &MaskedArray[T]) percentile[T](percentile f64) !MaskedValue[f64]

percentile computes a linearly interpolated percentile over unmasked values.

fn (MaskedArray[T]) percentile_with_method #

fn (array &MaskedArray[T]) percentile_with_method[T](percentile f64, method QuantileMethod) !MaskedValue[f64]

percentile_with_method computes a selected percentile over unmasked values.

fn (MaskedArray[T]) quantile_along_axis #

fn (array &MaskedArray[T]) quantile_along_axis[T](axis int, q f64, keepdims bool) !MaskedArray[f64]

quantile_along_axis computes one quantile per slice, optionally retaining the reduced axis with length one.

fn (MaskedArray[T]) quantile_along_axis_with_method #

fn (array &MaskedArray[T]) quantile_along_axis_with_method[T](axis int, q f64, method QuantileMethod, keepdims bool) !MaskedArray[f64]

quantile_along_axis_with_method computes one selected quantile per slice.

fn (MaskedArray[T]) percentile_along_axis #

fn (array &MaskedArray[T]) percentile_along_axis[T](axis int, percentile f64, keepdims bool) !MaskedArray[f64]

percentile_along_axis computes one percentile per axis slice.

fn (MaskedArray[T]) percentile_along_axis_with_method #

fn (array &MaskedArray[T]) percentile_along_axis_with_method[T](axis int, percentile f64, method QuantileMethod, keepdims bool) !MaskedArray[f64]

percentile_along_axis_with_method computes a selected percentile per slice.

fn (MaskedArray[T]) quantile_along_axes #

fn (array &MaskedArray[T]) quantile_along_axes[T](axes []int, q f64, keepdims bool) !MaskedArray[f64]

quantile_along_axes computes one quantile per slice over several axes. Slices with no valid values have a NaN payload and a true output mask.

fn (MaskedArray[T]) quantile_along_axes_with_method #

fn (array &MaskedArray[T]) quantile_along_axes_with_method[T](axes []int, q f64, method QuantileMethod, keepdims bool) !MaskedArray[f64]

quantile_along_axes_with_method reduces multiple axes with a selected estimator. Slices with no valid values have a NaN payload and true mask.

fn (MaskedArray[T]) percentile_along_axes #

fn (array &MaskedArray[T]) percentile_along_axes[T](axes []int, percentile f64, keepdims bool) !MaskedArray[f64]

percentile_along_axes computes one percentile per slice over several axes.

fn (MaskedArray[T]) percentile_along_axes_with_method #

fn (array &MaskedArray[T]) percentile_along_axes_with_method[T](axes []int, percentile f64, method QuantileMethod, keepdims bool) !MaskedArray[f64]

percentile_along_axes_with_method reduces several axes with a selected estimator on the 0..100 percentile scale.

fn (MaskedArray[T]) median_along_axis #

fn (array &MaskedArray[T]) median_along_axis[T](axis int, keepdims bool) !MaskedArray[f64]

median_along_axis computes the median of each unmasked axis slice.

fn (MaskedArray[T]) median_along_axes #

fn (array &MaskedArray[T]) median_along_axes[T](axes []int, keepdims bool) !MaskedArray[f64]

median_along_axes computes medians over several axes.

fn (MaskedArray[T]) sum_along_axis #

fn (array &MaskedArray[T]) sum_along_axis[T](axis int, keepdims bool) !MaskedArray[T]

sum_along_axis reduces unmasked values along one axis. Output mask entries are true for slices containing no unmasked values.

fn (MaskedArray[T]) sum_along_axes #

fn (array &MaskedArray[T]) sum_along_axes[T](axes []int, keepdims bool) !MaskedArray[T]

sum_along_axes reduces unmasked values over several axes. Negative axes are supported; duplicate axes are rejected. An empty axes list preserves data.

fn (MaskedArray[T]) prod_along_axis #

fn (array &MaskedArray[T]) prod_along_axis[T](axis int, keepdims bool) !MaskedArray[T]

prod_along_axis multiplies unmasked values along one axis.

fn (MaskedArray[T]) prod_along_axes #

fn (array &MaskedArray[T]) prod_along_axes[T](axes []int, keepdims bool) !MaskedArray[T]

prod_along_axes multiplies unmasked values over several axes. Negative axes are supported; duplicate axes are rejected. An empty axes list preserves data.

fn (MaskedArray[T]) min_along_axis #

fn (array &MaskedArray[T]) min_along_axis[T](axis int, keepdims bool) !MaskedArray[T]

min_along_axis finds the smallest unmasked value in each axis slice.

fn (MaskedArray[T]) min_along_axes #

fn (array &MaskedArray[T]) min_along_axes[T](axes []int, keepdims bool) !MaskedArray[T]

min_along_axes finds minima across several axes. Empty slices are masked.

fn (MaskedArray[T]) max_along_axis #

fn (array &MaskedArray[T]) max_along_axis[T](axis int, keepdims bool) !MaskedArray[T]

max_along_axis finds the largest unmasked value in each axis slice.

fn (MaskedArray[T]) max_along_axes #

fn (array &MaskedArray[T]) max_along_axes[T](axes []int, keepdims bool) !MaskedArray[T]

max_along_axes finds maxima across several axes. Empty slices are masked.

fn (MaskedArray[T]) variance_along_axis #

fn (array &MaskedArray[T]) variance_along_axis[T](axis int, ddof int, keepdims bool) !MaskedArray[f64]

variance_along_axis computes variance along one axis, marking slices with insufficient valid values as masked NaN results.

fn (MaskedArray[T]) variance_along_axes #

fn (array &MaskedArray[T]) variance_along_axes[T](axes []int, ddof int, keepdims bool) !MaskedArray[f64]

variance_along_axes computes population or sample variance over several axes. Empty axes compute elementwise zero variance for valid values.

fn (MaskedArray[T]) std_along_axis #

fn (array &MaskedArray[T]) std_along_axis[T](axis int, ddof int, keepdims bool) !MaskedArray[f64]

std_along_axis computes standard deviation along one axis.

fn (MaskedArray[T]) std_along_axes #

fn (array &MaskedArray[T]) std_along_axes[T](axes []int, ddof int, keepdims bool) !MaskedArray[f64]

std_along_axes computes standard deviation over several axes.

fn (MaskedArray[T]) mean_along_axis #

fn (array &MaskedArray[T]) mean_along_axis[T](axis int, keepdims bool) !MaskedArray[f64]

mean_along_axis computes the mean of unmasked values per axis slice. Slices with no unmasked values carry a masked NaN result.

fn (MaskedArray[T]) mean_along_axes #

fn (array &MaskedArray[T]) mean_along_axes[T](axes []int, keepdims bool) !MaskedArray[f64]

mean_along_axes computes means over several axes. Negative axes are supported; duplicate axes are rejected. An empty axes list converts each unmasked value to f64 and preserves the mask.

fn (MaskedArray[T]) weighted_average #

fn (array &MaskedArray[T]) weighted_average[T, W](weights &Tensor[W]) !MaskedValue[f64]

weighted_average computes a weighted mean over valid values. Weights must broadcast to the values shape; masked observations do not contribute either their value or their weight. An entirely masked array returns masked NaN.

fn (MaskedArray[T]) weighted_average_along_axis #

fn (array &MaskedArray[T]) weighted_average_along_axis[T, W](weights &Tensor[W], axis int, keepdims bool) !MaskedArray[f64]

weighted_average_along_axis computes weighted means per slice. Weights may broadcast to the values shape or be a vector matching the selected axis.

fn (MaskedArray[T]) weighted_average_along_axes #

fn (array &MaskedArray[T]) weighted_average_along_axes[T, W](weights &Tensor[W], axes []int, keepdims bool) !MaskedArray[f64]

weighted_average_along_axes reduces several dimensions. Weights must broadcast to the values shape; empty slices are masked and zero-sum valid weights return an error.

type PromotedTensor #

type PromotedTensor = &Tensor[bool]
	| &Tensor[i8]
	| &Tensor[i16]
	| &Tensor[i32]
	| &Tensor[i64]
	| &Tensor[int]
	| &Tensor[u8]
	| &Tensor[u16]
	| &Tensor[u32]
	| &Tensor[u64]
	| &Tensor[f32]
	| &Tensor[f64]
	| &Tensor[complex.Complex]

PromotedTensor is the dynamically selected result of binary_promoted_auto.

fn (ReadOnlyDiagonalView[T]) shape #

fn (view &ReadOnlyDiagonalView[T]) shape() []int

shape returns a copy of the view shape.

fn (ReadOnlyDiagonalView[T]) rank #

fn (view &ReadOnlyDiagonalView[T]) rank() int

rank returns the number of dimensions in the view.

fn (ReadOnlyDiagonalView[T]) size #

fn (view &ReadOnlyDiagonalView[T]) size() int

size returns the number of elements in the view.

fn (ReadOnlyDiagonalView[T]) get #

fn (view &ReadOnlyDiagonalView[T]) get(index []int) T

get reads the element at the given multidimensional index.

fn (ReadOnlyDiagonalView[T]) get_nth #

fn (view &ReadOnlyDiagonalView[T]) get_nth(index int) T

get_nth reads an element in logical row-major order.

fn (ReadOnlyDiagonalView[T]) to_array #

fn (view &ReadOnlyDiagonalView[T]) to_array() []T

to_array returns a copy of the view's logical values.

type Real #

type Real = i8
	| i16
	| i32
	| i64
	| int
	| u8
	| u16
	| u32
	| u64
	| uint
	| f32
	| f64

Real is the set of ordered built-in scalar types supported by reductions whose semantics require numeric ordering.

fn (TensorAxisIterator[T]) next #

@[inline]
fn (mut s TensorAxisIterator[T]) next[T]() ?(T, []int)

next exposes this operation as part of the public API.

type TensorDataType #

type TensorDataType = bool
	| f32
	| f64
	| i16
	| i32
	| i64
	| i8
	| int
	| string
	| u16
	| u32
	| u64
	| u8

TensorDataType is a sum type that lists the possible types to be used to define storage

fn (TensorDataType) string #

fn (v TensorDataType) string() string

string returns TensorDataType as a string.

fn (TensorDataType) int #

fn (v TensorDataType) int() int

int converts a numeric TensorDataType value to int.

fn (TensorDataType) i64 #

fn (v TensorDataType) i64() i64

i64 converts a numeric TensorDataType value to i64.

fn (TensorDataType) i32 #

fn (v TensorDataType) i32() i32

i32 converts a numeric TensorDataType value to i32.

fn (TensorDataType) i8 #

fn (v TensorDataType) i8() i8

i8 converts a numeric TensorDataType value to i8.

fn (TensorDataType) i16 #

fn (v TensorDataType) i16() i16

i16 converts a numeric TensorDataType value to i16.

fn (TensorDataType) u8 #

fn (v TensorDataType) u8() u8

u8 converts a numeric TensorDataType value to u8.

fn (TensorDataType) u16 #

fn (v TensorDataType) u16() u16

u16 converts a numeric TensorDataType value to u16.

fn (TensorDataType) u32 #

fn (v TensorDataType) u32() u32

u32 converts a numeric TensorDataType value to u32.

fn (TensorDataType) u64 #

fn (v TensorDataType) u64() u64

u64 converts a numeric TensorDataType value to u64.

fn (TensorDataType) f32 #

fn (v TensorDataType) f32() f32

f32 converts a numeric TensorDataType value to f32.

fn (TensorDataType) f64 #

fn (v TensorDataType) f64() f64

f64 converts a numeric TensorDataType value to f64.

fn (TensorDataType) bool #

fn (v TensorDataType) bool() bool

bool uses TensorDataType as a bool

fn (TensorIterator[T]) next #

@[inline]
fn (mut s TensorIterator[T]) next[T]() ?(T, []int)

next exposes this operation as part of the public API.

fn (Tensor[T]) cpu #

@[inline]
fn (t &Tensor[T]) cpu() !&Tensor[T]

cpu exposes this operation as part of the public API.

fn (Tensor[T]) str #

@[inline]
fn (t &Tensor[T]) str() string

str exposes this operation as part of the public API.

fn (Tensor[T]) rank #

fn (t &Tensor[T]) rank() int

rank returns the number of dimensions of a given Tensor

fn (Tensor[T]) size #

fn (t &Tensor[T]) size() int

size returns the number of allocated elements for a given tensor

fn (Tensor[T]) is_matrix #

@[inline]
fn (t &Tensor[T]) is_matrix() bool

is_matrix exposes this operation as part of the public API.

fn (Tensor[T]) is_square_matrix #

@[inline]
fn (t &Tensor[T]) is_square_matrix() bool

is_square_matrix exposes this operation as part of the public API.

fn (Tensor[T]) is_vector #

@[inline]
fn (t &Tensor[T]) is_vector() bool

is_vector exposes this operation as part of the public API.

fn (Tensor[T]) is_row_major #

@[inline]
fn (t &Tensor[T]) is_row_major() bool

is_row_major exposes this operation as part of the public API.

fn (Tensor[T]) is_col_major #

@[inline]
fn (t &Tensor[T]) is_col_major() bool

is_col_major exposes this operation as part of the public API.

fn (Tensor[T]) is_row_major_contiguous #

@[inline]
fn (t &Tensor[T]) is_row_major_contiguous() bool

is_row_major_contiguous exposes this operation as part of the public API.

fn (Tensor[T]) is_col_major_contiguous #

@[inline]
fn (t &Tensor[T]) is_col_major_contiguous() bool

is_col_major_contiguous exposes this operation as part of the public API.

fn (Tensor[T]) is_contiguous #

@[inline]
fn (t &Tensor[T]) is_contiguous() bool

is_contiguous exposes this operation as part of the public API.

fn (Tensor[T]) to_array #

fn (t &Tensor[T]) to_array() []T

to_array returns the flatten representation of a tensor in a v array storing elements of type T

fn (Tensor[T]) copy #

@[inline]
fn (t &Tensor[T]) copy(memory MemoryFormat) &Tensor[T]

copy exposes this operation as part of the public API.

fn (Tensor[T]) view #

@[inline]
fn (t &Tensor[T]) view() &Tensor[T]

view exposes this operation as part of the public API.

fn (Tensor[T]) clone #

fn (t &Tensor[T]) clone() &Tensor[T]

clone returns an owning contiguous copy of the tensor with the same shape and memory format. Logical elements are copied in order via get_nth/set_nth and contiguous strides are recalculated, so cloning a non-contiguous view (e.g. a slice whose physical span exceeds its size) yields correct values. Unlike view, mutating the clone cannot affect the source.

fn (Tensor[T]) set #

@[inline]
fn (mut t Tensor[T]) set[T](index []int, val T)

set copies a scalar value into a Tensor at the provided index. Negative coordinates count from the end of each axis; invalid coordinates panic. Use set_checked when bounds errors must be returned to the caller.

fn (Tensor[T]) set_checked #

fn (mut t Tensor[T]) set_checked[T](index []int, val T) !

set_checked copies a value at index, or returns an error if the index rank or any coordinate is outside the tensor bounds.

fn (Tensor[T]) set_nth #

@[inline]
fn (mut t Tensor[T]) set_nth[T](n int, val T)

set_nth exposes this operation as part of the public API.

fn (Tensor[T]) fill #

@[inline]
fn (mut t Tensor[T]) fill[T](val T) &Tensor[T]

fill exposes this operation as part of the public API.

fn (Tensor[T]) assign #

fn (mut t Tensor[T]) assign[T](other &Tensor[T]) !&Tensor[T]

assign sets the values of an Tensor equal to the values of another Tensor of the same shape

fn (Tensor[T]) put #

fn (mut t Tensor[T]) put[T](indices &Tensor[int], values &Tensor[T]) !

put replaces values at row-major logical flat indices. Values repeat when there are fewer values than indices. Negative indices count from the end. Invalid indices return an error without changing the tensor.

fn (Tensor[T]) putmask #

@[direct_array_access]
fn (mut t Tensor[T]) putmask[T](mask &Tensor[bool], values &Tensor[T]) !

putmask replaces values where mask is true, in row-major logical order. Update values repeat cyclically by row-major flat position, matching NumPy's putmask semantics. The mask must match the tensor shape exactly.

fn (Tensor[T]) put_with_mode #

fn (mut t Tensor[T]) put_with_mode[T](indices &Tensor[int], values &Tensor[T], mode PutMode) !

put_with_mode replaces values at row-major logical flat indices, using mode to handle indices outside the flattened tensor's range. Repeated indices follow row-major write order, so the last value wins. All indices are validated before any writes are made.

fn (Tensor[T]) put_along_axis #

fn (mut t Tensor[T]) put_along_axis[T](indices &Tensor[int], values &Tensor[T], axis int) !

put_along_axis writes values at indices along axis. Indices and values must have the same rank as the target and values must match the index shape. The index dimensions outside axis may be smaller than the target dimensions. Negative indices count from the end. When an index is repeated, the last value in row-major iteration order wins. Out-of-range indices return an error before any target values are changed.

fn (Tensor[T]) scatter_add #

fn (mut t Tensor[T]) scatter_add[T](indices &Tensor[int], values &Tensor[T], axis int) !

scatter_add adds values at indices along axis. Duplicate indices accumulate in row-major iteration order; negative indices count from the end. An out-of-range index returns an error before any target values are changed.

fn (Tensor[T]) bitwise_and #

fn (a &Tensor[T]) bitwise_and[T](b &Tensor[T]) !&Tensor[T]

bitwise_and computes the elementwise bitwise AND with tensor broadcasting.

fn (Tensor[T]) bitwise_or #

fn (a &Tensor[T]) bitwise_or[T](b &Tensor[T]) !&Tensor[T]

bitwise_or computes the elementwise bitwise OR with tensor broadcasting.

fn (Tensor[T]) bitwise_xor #

fn (a &Tensor[T]) bitwise_xor[T](b &Tensor[T]) !&Tensor[T]

bitwise_xor computes the elementwise bitwise XOR with tensor broadcasting.

fn (Tensor[T]) bitwise_invert #

fn (t &Tensor[T]) bitwise_invert[T]() &Tensor[T]

bitwise_invert computes the elementwise one's complement.

fn (Tensor[T]) left_shift #

fn (t &Tensor[T]) left_shift[T](shift int) !&Tensor[T]

left_shift shifts every integer value left by a scalar number of bits.

fn (Tensor[T]) right_shift #

fn (t &Tensor[T]) right_shift[T](shift int) !&Tensor[T]

right_shift shifts every integer value right by a scalar number of bits.

fn (Tensor[T]) broadcastable #

fn (a &Tensor[T]) broadcastable[T](b &Tensor[T]) ![]int

broadcastable takes two Tensors and either returns a valid broadcastable shape or an error

fn (Tensor[T]) broadcast_to #

fn (t &Tensor[T]) broadcast_to[T](shape []int) !&Tensor[T]

broadcast_to broadcasts a Tensor to a compatible shape with no data copy

fn (Tensor[T]) as_bool #

@[inline]
fn (t &Tensor[T]) as_bool[T]() &Tensor[bool]

as_bool exposes this operation as part of the public API.

fn (Tensor[T]) as_f32 #

@[inline]
fn (t &Tensor[T]) as_f32[T]() &Tensor[f32]

as_f32 exposes this operation as part of the public API.

fn (Tensor[T]) as_f64 #

@[inline]
fn (t &Tensor[T]) as_f64[T]() &Tensor[f64]

as_f64 exposes this operation as part of the public API.

fn (Tensor[T]) as_i64 #

fn (t &Tensor[T]) as_i64[T]() &Tensor[i64]

as_i64 casts each tensor value to i64 while preserving its logical shape.

fn (Tensor[T]) as_i32 #

fn (t &Tensor[T]) as_i32[T]() &Tensor[i32]

as_i32 casts each tensor value to i32 while preserving its logical shape.

fn (Tensor[T]) as_i16 #

@[inline]
fn (t &Tensor[T]) as_i16[T]() &Tensor[i16]

as_i16 exposes this operation as part of the public API.

fn (Tensor[T]) as_i8 #

@[inline]
fn (t &Tensor[T]) as_i8[T]() &Tensor[i8]

as_i8 exposes this operation as part of the public API.

fn (Tensor[T]) as_int #

@[inline]
fn (t &Tensor[T]) as_int[T]() &Tensor[int]

as_int exposes this operation as part of the public API.

fn (Tensor[T]) as_string #

@[inline]
fn (t &Tensor[T]) as_string[T]() &Tensor[string]

as_string exposes this operation as part of the public API.

fn (Tensor[T]) as_u8 #

@[inline]
fn (t &Tensor[T]) as_u8[T]() &Tensor[u8]

as_u8 exposes this operation as part of the public API.

fn (Tensor[T]) as_u16 #

fn (t &Tensor[T]) as_u16[T]() &Tensor[u16]

as_u16 casts each tensor value to u16 while preserving its logical shape.

fn (Tensor[T]) as_u32 #

fn (t &Tensor[T]) as_u32[T]() &Tensor[u32]

as_u32 casts each tensor value to u32 while preserving its logical shape.

fn (Tensor[T]) as_u64 #

fn (t &Tensor[T]) as_u64[T]() &Tensor[u64]

as_u64 casts each tensor value to u64 while preserving its logical shape.

fn (Tensor[T]) dtype #

fn (t &Tensor[T]) dtype[T]() DType

dtype returns the element dtype of the receiver tensor.

fn (Tensor[T]) apply #

fn (mut t Tensor[T]) apply[T](f fn (x T, i []int) T)

apply applies a function to each element of a given Tensor

fn (Tensor[T]) map #

fn (t &Tensor[T]) map[T](f fn (x T, i []int) T) &Tensor[T]

map maps a function to a given Tensor retuning a new Tensor with same shape

fn (Tensor[T]) map_values #

@[direct_array_access]
fn (t &Tensor[T]) map_values[T](f fn (x T) T) &Tensor[T]

map_values applies a value-only function to each element, without passing its multidimensional index. It uses direct linear access for contiguous row-major storage and falls back to map for views and non-contiguous tensors.

fn (Tensor[T]) map_pair_values #

@[direct_array_access]
fn (a &Tensor[T]) map_pair_values[T](b &Tensor[T], f fn (x T, y T) T) !&Tensor[T]

map_pair_values applies a value-only binary function with standard tensor broadcasting. Equal-shaped contiguous row-major tensors use direct linear access; broadcasting and non-contiguous inputs use nmap.

fn (Tensor[T]) reduce #

fn (t &Tensor[T]) reduce[T](init T, f fn (acc T, x T, i []int) T) T

reduce reduces a function to a given Tensor retuning a new aggregated value

fn (Tensor[T]) napply #

fn (mut t Tensor[T]) napply[T](ts []&Tensor[T], f fn (xs []T, i []int) T) !

napply applies a function to each element of a given Tensor with params

fn (Tensor[T]) nmap #

fn (t &Tensor[T]) nmap[T](ts []&Tensor[T], f fn (xs []T, i []int) T) !&Tensor[T]

nmap maps a function to a given list of Tensor retuning a new Tensor with same shape

fn (Tensor[T]) nreduce #

fn (t &Tensor[T]) nreduce[T](ts []&Tensor[T], init T, f fn (acc T, xs []T, i []int) T) !T

nreduce reduces a function to a given list of Tensor retuning a new aggregated value

fn (Tensor[T]) with_dims #

fn (t &Tensor[T]) with_dims[T](n int) !&Tensor[T]

with_dims returns a new Tensor adding dimensions so that it has at least n dimensions

fn (Tensor[T]) with_broadcast #

fn (t &Tensor[T]) with_broadcast[T](n int) !&Tensor[T]

with_broadcast expands a Tensors dimensions n times by broadcasting the shape and strides

fn (Tensor[T]) diagonal #

fn (t &Tensor[T]) diagonal[T]() &Tensor[T]

diagonal returns a view of the diagonal entries of a two dimensional tensor

fn (Tensor[T]) ravel #

@[inline]
fn (t &Tensor[T]) ravel[T]() !&Tensor[T]

ravel returns a one-dimensional tensor in row-major logical order. It shares storage for row-major contiguous tensors and copies non-contiguous tensors.

fn (Tensor[T]) flatten #

fn (t &Tensor[T]) flatten[T]() !&Tensor[T]

flatten returns a one-dimensional copy of a tensor in row-major logical order, even when the input is already contiguous.

fn (Tensor[T]) reshape #

fn (t &Tensor[T]) reshape[T](shape []int) !&Tensor[T]

reshape returns a Tensor with a new shape in row-major logical order. Row-major contiguous tensors share storage; other layouts are copied.

fn (Tensor[T]) as_strided #

fn (t &Tensor[T]) as_strided[T](shape []int, strides []int) !&Tensor[T]

as_strided returns a view of the Tensor with new shape and strides

fn (Tensor[T]) transpose #

@[direct_array_access]
fn (t &Tensor[T]) transpose[T](order []int) !&Tensor[T]

transpose exposes this operation as part of the public API.

fn (Tensor[T]) t #

fn (t &Tensor[T]) t[T]() !&Tensor[T]

t returns a full transpose of a tensor, with the axes reversed

fn (Tensor[T]) swapaxes #

fn (t &Tensor[T]) swapaxes[T](a1 int, a2 int) !&Tensor[T]

swapaxes returns a view of an tensor with two axes swapped

fn (Tensor[T]) moveaxis #

fn (t &Tensor[T]) moveaxis[T](source []int, destination []int) !&Tensor[T]

moveaxis returns a view with the axes in source moved to destination. Axis positions may be negative, and the remaining axes keep their order.

fn (Tensor[T]) rollaxis #

fn (t &Tensor[T]) rollaxis[T](axis int, start int) !&Tensor[T]

rollaxis moves axis backwards until it lies before start and returns a view. Negative axis positions are counted from the end of the tensor.

fn (Tensor[T]) slice #

@[direct_array_access]
fn (t &Tensor[T]) slice[T](idx ...[]int) !&Tensor[T]

slice exposes this operation as part of the public API.

fn (Tensor[T]) slice_hilo #

@[direct_array_access]
fn (t &Tensor[T]) slice_hilo[T](idx1 []int, idx2 []int) !&Tensor[T]

slice_hilo exposes this operation as part of the public API.

fn (Tensor[T]) all #

@[direct_array_access]
fn (t &Tensor[T]) all[T]() bool

all returns whether all array elements evaluate to true.

fn (Tensor[T]) any #

@[direct_array_access]
fn (t &Tensor[T]) any[T]() bool

any returns whether any array elements evaluate to true.

fn (Tensor[T]) logical_and #

fn (a &Tensor[T]) logical_and[T](b &Tensor[T]) !&Tensor[bool]

logical_and evaluates element truth values with standard tensor broadcasting.

fn (Tensor[T]) logical_or #

fn (a &Tensor[T]) logical_or[T](b &Tensor[T]) !&Tensor[bool]

logical_or evaluates element truth values with standard tensor broadcasting.

fn (Tensor[T]) logical_xor #

fn (a &Tensor[T]) logical_xor[T](b &Tensor[T]) !&Tensor[bool]

logical_xor evaluates element truth values with standard tensor broadcasting.

fn (Tensor[T]) logical_not #

fn (t &Tensor[T]) logical_not[T]() &Tensor[bool]

logical_not negates the truth value of each tensor element.

fn (Tensor[T]) all_axis #

fn (t &Tensor[T]) all_axis[T](axis int, keepdims bool) !&Tensor[bool]

all_axis reduces one axis with logical AND. The reduced dimension is removed unless keepdims is true. Empty reductions follow NumPy's identity: true.

fn (Tensor[T]) any_axis #

fn (t &Tensor[T]) any_axis[T](axis int, keepdims bool) !&Tensor[bool]

any_axis reduces one axis with logical OR. The reduced dimension is removed unless keepdims is true. Empty reductions follow NumPy's identity: false.

fn (Tensor[T]) all_axes #

fn (t &Tensor[T]) all_axes[T](axes []int, keepdims bool) !&Tensor[bool]

all_axes reduces multiple axes with logical AND. Axes may be negative and must be unique. An empty axes list converts values to bool without reducing.

fn (Tensor[T]) any_axes #

fn (t &Tensor[T]) any_axes[T](axes []int, keepdims bool) !&Tensor[bool]

any_axes reduces multiple axes with logical OR. Axes may be negative and must be unique. An empty axes list converts values to bool without reducing.

fn (Tensor[T]) is_finite #

fn (t &Tensor[T]) is_finite[T]() &Tensor[bool]

is_finite returns true where x is not positive infinity, negative infinity, or NaN; false otherwise.

fn (Tensor[T]) is_inf #

fn (t &Tensor[T]) is_inf[T](sign int) &Tensor[bool]

is_inf reports whether t is an infinity, according to sign. If sign > 0, is_inf reports whether t is positive infinity. If sign < 0, is_inf reports whether t is negative infinity. If sign == 0, is_inf reports whether t is either infinity.

fn (Tensor[T]) is_nan #

fn (t &Tensor[T]) is_nan[T]() &Tensor[bool]

is_nan returns true for NaN values and false for finite values and infinities.

fn (Tensor[T]) is_real #

fn (t &Tensor[T]) is_real[T]() &Tensor[bool]

is_real returns true for values with no imaginary component. For complex values, the imaginary component must compare equal to zero.

fn (Tensor[T]) is_complex #

fn (t &Tensor[T]) is_complex[T]() &Tensor[bool]

is_complex returns true for complex values with a nonzero imaginary component. NaN imaginary components are considered complex.

fn (Tensor[T]) array_equal #

fn (t &Tensor[T]) array_equal[T](other &Tensor[T]) bool

array_equal returns true if input arrays have the same shape and all elements compare exactly equal. Floating-point NaNs compare unequal; use isclose for approximate comparisons.

fn (Tensor[T]) array_equiv #

fn (t &Tensor[T]) array_equiv[T](other &Tensor[T]) bool

array_equiv returns true if input arrays are shape consistent and all elements equal. Shape consistent means they are either the same shape, or one input array can be broadcasted to create the same shape as the other one.

fn (Tensor[T]) equal #

@[direct_array_access]
fn (t &Tensor[T]) equal[T](other &Tensor[T]) !&Tensor[bool]

equal exposes this operation as part of the public API.

fn (Tensor[T]) not_equal #

@[direct_array_access]
fn (t &Tensor[T]) not_equal[T](other &Tensor[T]) !&Tensor[bool]

not_equal exposes this operation as part of the public API.

fn (Tensor[T]) tolerance #

@[inline]
fn (t &Tensor[T]) tolerance[T](other &Tensor[T], tol T) !&Tensor[bool]

tolerance compares two tensors elementwise with a given tolerance.

fn (Tensor[T]) close #

@[inline]
fn (t &Tensor[T]) close[T](other &Tensor[T]) !&Tensor[bool]

close exposes this operation as part of the public API.

fn (Tensor[T]) veryclose #

@[inline]
fn (t &Tensor[T]) veryclose[T](other &Tensor[T]) !&Tensor[bool]

veryclose exposes this operation as part of the public API.

fn (Tensor[T]) alike #

@[inline]
fn (t &Tensor[T]) alike[T](other &Tensor[T]) !&Tensor[bool]

alike exposes this operation as part of the public API.

fn (Tensor[T]) isclose #

@[direct_array_access]
fn (t &Tensor[T]) isclose[T](other &Tensor[T], params IsCloseData) !&Tensor[bool]

isclose compares tensors elementwise using NumPy's asymmetric tolerance rule: abs(a - b) <= atol + rtol * abs(b). The returned tensor has the broadcast shape of the inputs. NaNs compare false unless equal_nan is true.

fn (Tensor[T]) allclose #

@[direct_array_access]
fn (t &Tensor[T]) allclose[T](other &Tensor[T], params IsCloseData) !bool

allclose returns true if all broadcasted elements satisfy isclose.

fn (Tensor[T]) iterator #

fn (t &Tensor[T]) iterator[T]() &TensorIterator[T]

iterator creates an iterator through a Tensor

fn (Tensor[T]) custom_iterator #

fn (t &Tensor[T]) custom_iterator[T](data IteratorBuildData[T]) &TensorIterator[T]

iterator creates an iterator through a Tensor with custom data

fn (Tensor[T]) iterators #

fn (t &Tensor[T]) iterators[T](ts []&Tensor[T]) !(&TensorsIterator[T], []int)

iterators creates an array of iterators through a list of tensors

fn (Tensor[T]) axis_iterator #

fn (t &Tensor[T]) axis_iterator[T](axis int) &TensorAxisIterator[T]

axis_iterator returns an iterator over the axis of a Tensor, commonly used for reduction operations along an axis.

fn (Tensor[T]) axis_with_dims_iterator #

fn (t &Tensor[T]) axis_with_dims_iterator[T](axis int) &TensorAxisIterator[T]

axis returns an iterator over the axis of a Tensor, commonly used for reduction operations along an axis. This iterator keeps the axis dimension as size 1 instead of removing it

fn (Tensor[T]) take #

fn (t &Tensor[T]) take[T](indices []int, axis int) !&Tensor[T]

take returns a copy of the tensor with the values at indices selected along axis. Negative axes and negative indices count from the end. The indices are a one-dimensional list; use slice for range-based views.

fn (Tensor[T]) take_with_mode #

fn (t &Tensor[T]) take_with_mode[T](indices []int, axis int, mode TakeMode) !&Tensor[T]

take_with_mode selects values along axis, handling out-of-range indices with the requested mode. In .clip mode, negative values clip to zero, matching NumPy's take behavior.

fn (Tensor[T]) take_nd #

fn (t &Tensor[T]) take_nd[T](indices &Tensor[int], axis int) !&Tensor[T]

take_nd gathers values along one axis using an index tensor. The index tensor's dimensions replace the selected axis in the output shape.

fn (Tensor[T]) take_nd_with_mode #

fn (t &Tensor[T]) take_nd_with_mode[T](indices &Tensor[int], axis int, mode TakeMode) !&Tensor[T]

take_nd_with_mode gathers with an index tensor and applies mode to every index. The index tensor's dimensions replace the selected axis.

fn (Tensor[T]) take_flat #

fn (t &Tensor[T]) take_flat[T](indices &Tensor[int]) !&Tensor[T]

take_flat gathers from the row-major logical flattening of a tensor and preserves the shape of the index tensor.

fn (Tensor[T]) take_flat_with_mode #

fn (t &Tensor[T]) take_flat_with_mode[T](indices &Tensor[int], mode TakeMode) !&Tensor[T]

take_flat_with_mode gathers from row-major logical order and applies mode to indices outside the flattened tensor's range.

fn (Tensor[T]) take_along_axis #

fn (t &Tensor[T]) take_along_axis[T](indices &Tensor[int], axis int) !&Tensor[T]

take_along_axis gathers values using an index tensor with the same rank as the receiver. Non-axis dimensions broadcast; the result's axis length is taken from the index tensor. Negative indices count from the end.

fn (Tensor[T]) get #

@[inline]
fn (t &Tensor[T]) get[T](index []int) T

get exposes this operation as part of the public API.

fn (Tensor[T]) get_checked #

fn (t &Tensor[T]) get_checked[T](index []int) !T

get_checked returns a scalar value at index, or an error if the index rank or any coordinate is outside the tensor bounds. Negative coordinates count from the end of their axis.

fn (Tensor[T]) get_nth #

@[inline]
fn (t &Tensor[T]) get_nth[T](n int) T

get_nth exposes this operation as part of the public API.

fn (Tensor[T]) offset_index #

@[inline]
fn (t &Tensor[T]) offset_index[T](index []int) int

offset_index exposes this operation as part of the public API.

fn (Tensor[T]) nth_index #

fn (t &Tensor[T]) nth_index[T](n int) []int

nth_index returns the nth index of a Tensor's shape for n == 2 and a shape of [2, 2] the nth index is [1, 0] and for a shape of [2, 3] and n == 3 the nth index is [0, 1, 1] in sorted order.

fn (Tensor[T]) flip #

fn (t &Tensor[T]) flip[T](axes ...int) !&Tensor[T]

flip returns a copy of t with the selected axes reversed. With no axes, all axes are reversed, matching NumPy's flip default. Negative axes are accepted.

fn (Tensor[T]) masked_select #

fn (t &Tensor[T]) masked_select[T](mask &Tensor[bool]) !&Tensor[T]

masked_select returns the values whose corresponding mask entries are true. The mask must be broadcastable to the tensor shape; values are returned in row-major logical order, including for non-contiguous views.

fn (Tensor[T]) masked_fill #

fn (t &Tensor[T]) masked_fill[T](mask &Tensor[bool], value T) !&Tensor[T]

masked_fill returns a tensor with mask-selected values replaced by value. The mask must be broadcastable to the tensor shape.

fn (Tensor[T]) masked_scatter #

fn (t &Tensor[T]) masked_scatter[T](mask &Tensor[bool], source &Tensor[T]) !&Tensor[T]

masked_scatter copies source values, in row-major order, into the true positions selected by a broadcastable mask. The source must contain at least as many values as the mask selects; extra source values are ignored.

fn (Tensor[T]) diag #

fn (t &Tensor[T]) diag[T]() !&Tensor[T]

diag constructs a diagonal array. input must be one dimensional and will be placed along the resulting diagonal

fn (Tensor[T]) diag_flat #

fn (t &Tensor[T]) diag_flat[T]() !&Tensor[T]

diag_flat constructs a diagonal array. the flattened input is placed along the diagonal of the resulting matrix

fn (Tensor[T]) tril #

fn (t &Tensor[T]) tril[T]() &Tensor[T]

tril computes the lower triangle of an array. returns a copy of an array with elements above the diagonal zeroed

fn (Tensor[T]) tril_offset #

fn (t &Tensor[T]) tril_offset[T](offset int) &Tensor[T]

tril_inplace computes the lower triangle of an array. returns a copy of an array with elements above the kth diagonal zeroed

fn (Tensor[T]) tril_inplace #

fn (mut t Tensor[T]) tril_inplace[T]() &Tensor[T]

tril_inplace computes the lower triangle of an array. modifies an array inplace with elements above the diagonal zeroed.

fn (Tensor[T]) tril_inpl_offset #

fn (mut t Tensor[T]) tril_inpl_offset[T](offset int) &Tensor[T]

tril_inpl_offset computes the lower triangle of an array. modifies an array inplace with elements above the k-th diagonal zeroed.

fn (Tensor[T]) triu #

fn (t &Tensor[T]) triu[T]() &Tensor[T]

triu computes the Upper triangle of an array. returns a copy of an array with elements below the diagonal zeroed

fn (Tensor[T]) triu_offset #

fn (t &Tensor[T]) triu_offset[T](offset int) &Tensor[T]

triu_offset computes the upper triangle of an array. returns a copy of an array with elements below the kth diagonal zeroed

fn (Tensor[T]) triu_inplace #

fn (mut t Tensor[T]) triu_inplace[T]() &Tensor[T]

triu_inplace computes the upper triangle of an array. modifies an array inplace with elements below the diagonal zeroed.

fn (Tensor[T]) nan_to_num #

fn (t &Tensor[T]) nan_to_num[T](params NanToNumConfig) &Tensor[T]

nan_to_num replaces NaN and positive or negative infinity in floating-point tensors. Complex values are handled component-wise; other types are copied.

fn (Tensor[T]) sign #

fn (t &Tensor[T]) sign[T]() &Tensor[T]

sign returns the elementwise sign of each value: -1, 0, or 1. Floating-point NaNs remain NaN. Complex values return their normalized phase, matching NumPy 2.0 and later.

fn (Tensor[T]) heaviside #

fn (t &Tensor[T]) heaviside[T](x1 T) &Tensor[T]

heaviside returns 0 for negative values, 1 for positive values, and x1 for zero values. Floating-point NaNs remain NaN.

fn (Tensor[T]) clip #

fn (t &Tensor[T]) clip[T](min_value T, max_value T) !&Tensor[T]

clip limits tensor values to the inclusive scalar interval [min_value, max_value]. The tensor element type is preserved; NaN values remain NaN.

fn (Tensor[T]) abs #

@[inline]
fn (t &Tensor[T]) abs[T]() &Tensor[T]

abs exposes this operation as part of the public API.

fn (Tensor[T]) acos #

@[inline]
fn (t &Tensor[T]) acos[T]() &Tensor[T]

acos exposes this operation as part of the public API.

fn (Tensor[T]) acosh #

@[inline]
fn (t &Tensor[T]) acosh[T]() &Tensor[T]

acosh exposes this operation as part of the public API.

fn (Tensor[T]) asin #

@[inline]
fn (t &Tensor[T]) asin[T]() &Tensor[T]

asin exposes this operation as part of the public API.

fn (Tensor[T]) asinh #

@[inline]
fn (t &Tensor[T]) asinh[T]() &Tensor[T]

asinh exposes this operation as part of the public API.

fn (Tensor[T]) atan #

@[inline]
fn (t &Tensor[T]) atan[T]() &Tensor[T]

atan exposes this operation as part of the public API.

fn (Tensor[T]) atan2 #

@[inline]
fn (a &Tensor[T]) atan2[T](b &Tensor[T]) !&Tensor[T]

atan2 exposes this operation as part of the public API.

fn (Tensor[T]) atanh #

@[inline]
fn (t &Tensor[T]) atanh[T]() &Tensor[T]

atanh exposes this operation as part of the public API.

fn (Tensor[T]) cbrt #

@[inline]
fn (t &Tensor[T]) cbrt[T]() &Tensor[T]

cbrt exposes this operation as part of the public API.

fn (Tensor[T]) ceil #

@[inline]
fn (t &Tensor[T]) ceil[T]() &Tensor[T]

ceil exposes this operation as part of the public API.

fn (Tensor[T]) cos #

@[inline]
fn (t &Tensor[T]) cos[T]() &Tensor[T]

cos exposes this operation as part of the public API.

fn (Tensor[T]) cosh #

@[inline]
fn (t &Tensor[T]) cosh[T]() &Tensor[T]

cosh exposes this operation as part of the public API.

fn (Tensor[T]) cot #

@[inline]
fn (t &Tensor[T]) cot[T]() &Tensor[T]

cot exposes this operation as part of the public API.

fn (Tensor[T]) degrees #

@[inline]
fn (t &Tensor[T]) degrees[T]() &Tensor[T]

degrees exposes this operation as part of the public API.

fn (Tensor[T]) erf #

@[inline]
fn (t &Tensor[T]) erf[T]() &Tensor[T]

erf exposes this operation as part of the public API.

fn (Tensor[T]) erfc #

@[inline]
fn (t &Tensor[T]) erfc[T]() &Tensor[T]

erfc exposes this operation as part of the public API.

fn (Tensor[T]) exp #

@[inline]
fn (t &Tensor[T]) exp[T]() &Tensor[T]

exp exposes this operation as part of the public API.

fn (Tensor[T]) exp2 #

@[inline]
fn (t &Tensor[T]) exp2[T]() &Tensor[T]

exp2 exposes this operation as part of the public API.

fn (Tensor[T]) expm1 #

@[inline]
fn (t &Tensor[T]) expm1[T]() &Tensor[T]

expm1 exposes this operation as part of the public API.

fn (Tensor[T]) f32_bits #

@[inline]
fn (t &Tensor[T]) f32_bits[T]() &Tensor[T]

f32_bits exposes this operation as part of the public API.

fn (Tensor[T]) f32_from_bits #

@[inline]
fn (t &Tensor[T]) f32_from_bits[T]() &Tensor[T]

f32_from_bits exposes this operation as part of the public API.

fn (Tensor[T]) f64_bits #

@[inline]
fn (t &Tensor[T]) f64_bits[T]() &Tensor[T]

f64_bits exposes this operation as part of the public API.

fn (Tensor[T]) f64_from_bits #

@[inline]
fn (t &Tensor[T]) f64_from_bits[T]() &Tensor[T]

f64_from_bits exposes this operation as part of the public API.

fn (Tensor[T]) factorial #

@[inline]
fn (t &Tensor[T]) factorial[T]() &Tensor[T]

factorial exposes this operation as part of the public API.

fn (Tensor[T]) floor #

@[inline]
fn (t &Tensor[T]) floor[T]() &Tensor[T]

floor exposes this operation as part of the public API.

fn (Tensor[T]) fmod #

@[inline]
fn (a &Tensor[T]) fmod[T](b &Tensor[T]) !&Tensor[T]

fmod exposes this operation as part of the public API.

fn (Tensor[T]) gamma #

@[inline]
fn (t &Tensor[T]) gamma[T]() &Tensor[T]

gamma exposes this operation as part of the public API.

fn (Tensor[T]) gcd #

@[inline]
fn (a &Tensor[T]) gcd[T](b &Tensor[T]) !&Tensor[T]

gcd exposes this operation as part of the public API.

fn (Tensor[T]) hypot #

@[inline]
fn (a &Tensor[T]) hypot[T](b &Tensor[T]) !&Tensor[T]

hypot exposes this operation as part of the public API.

fn (Tensor[T]) lcm #

@[inline]
fn (a &Tensor[T]) lcm[T](b &Tensor[T]) !&Tensor[T]

lcm exposes this operation as part of the public API.

fn (Tensor[T]) log #

@[inline]
fn (t &Tensor[T]) log[T]() &Tensor[T]

log exposes this operation as part of the public API.

fn (Tensor[T]) log10 #

@[inline]
fn (t &Tensor[T]) log10[T]() &Tensor[T]

log10 exposes this operation as part of the public API.

fn (Tensor[T]) log1p #

@[inline]
fn (t &Tensor[T]) log1p[T]() &Tensor[T]

log1p exposes this operation as part of the public API.

fn (Tensor[T]) log2 #

@[inline]
fn (t &Tensor[T]) log2[T]() &Tensor[T]

log2 exposes this operation as part of the public API.

fn (Tensor[T]) log_factorial #

@[inline]
fn (t &Tensor[T]) log_factorial[T]() &Tensor[T]

log_factorial exposes this operation as part of the public API.

fn (Tensor[T]) log_gamma #

@[inline]
fn (t &Tensor[T]) log_gamma[T]() &Tensor[T]

log_gamma exposes this operation as part of the public API.

fn (Tensor[T]) log_n #

@[inline]
fn (a &Tensor[T]) log_n[T](b &Tensor[T]) !&Tensor[T]

log_n exposes this operation as part of the public API.

fn (Tensor[T]) max #

@[inline]
fn (a &Tensor[T]) max[T](b &Tensor[T]) !&Tensor[T]

max returns the elementwise maximum and propagates NaNs, like numpy.maximum.

fn (Tensor[T]) min #

@[inline]
fn (a &Tensor[T]) min[T](b &Tensor[T]) !&Tensor[T]

min returns the elementwise minimum and propagates NaNs, like numpy.minimum.

fn (Tensor[T]) fmax #

@[inline]
fn (a &Tensor[T]) fmax[T](b &Tensor[T]) !&Tensor[T]

fmax returns the elementwise maximum, ignoring a single NaN operand, like numpy.fmax. If both operands are NaN, the left operand is returned.

fn (Tensor[T]) fmin #

@[inline]
fn (a &Tensor[T]) fmin[T](b &Tensor[T]) !&Tensor[T]

fmin returns the elementwise minimum, ignoring a single NaN operand, like numpy.fmin. If both operands are NaN, the left operand is returned.

fn (Tensor[T]) nextafter #

@[inline]
fn (a &Tensor[T]) nextafter[T](b &Tensor[T]) !&Tensor[T]

nextafter exposes this operation as part of the public API.

fn (Tensor[T]) nextafter32 #

@[inline]
fn (a &Tensor[T]) nextafter32[T](b &Tensor[T]) !&Tensor[T]

nextafter32 exposes this operation as part of the public API.

fn (Tensor[T]) pow #

@[inline]
fn (a &Tensor[T]) pow[T](b &Tensor[T]) !&Tensor[T]

pow exposes this operation as part of the public API.

fn (Tensor[T]) square #

fn (t &Tensor[T]) square[T]() !&Tensor[T]

square returns the elementwise square while preserving the tensor dtype.

fn (Tensor[T]) square_into #

fn (t &Tensor[T]) square_into[T](mut out Tensor[T]) !&Tensor[T]

square_into writes the elementwise square to a same-shaped output tensor. Internally overlapping or ambiguous output layouts are rejected. Overlapping input and output storage is safe; input values are snapshotted before writes.

fn (Tensor[T]) pow10 #

@[inline]
fn (t &Tensor[T]) pow10[T]() &Tensor[T]

pow10 exposes this operation as part of the public API.

fn (Tensor[T]) radians #

@[inline]
fn (t &Tensor[T]) radians[T]() &Tensor[T]

radians exposes this operation as part of the public API.

fn (Tensor[T]) round #

@[inline]
fn (t &Tensor[T]) round[T]() &Tensor[T]

round exposes this operation as part of the public API.

fn (Tensor[T]) round_to_even #

@[inline]
fn (t &Tensor[T]) round_to_even[T]() &Tensor[T]

round_to_even exposes this operation as part of the public API.

fn (Tensor[T]) round_decimals #

fn (t &Tensor[T]) round_decimals[T](decimals int) &Tensor[T]

round_decimals rounds real floating-point elements to a decimal position, following NumPy's ties-to-even rule. Negative decimals round to tens, hundreds, and larger place values. Integer tensors are copied unchanged.

fn (Tensor[T]) sin #

@[inline]
fn (t &Tensor[T]) sin[T]() &Tensor[T]

sin exposes this operation as part of the public API.

fn (Tensor[T]) sinc #

fn (t &Tensor[T]) sinc[T]() !&Tensor[T]

sinc returns sin(pix)/(pix) elementwise, with a value of 1 at either signed zero. Only f32 and f64 tensors are supported; the input dtype and shape are preserved.

fn (Tensor[T]) sinh #

@[inline]
fn (t &Tensor[T]) sinh[T]() &Tensor[T]

sinh exposes this operation as part of the public API.

fn (Tensor[T]) sqrt #

@[inline]
fn (t &Tensor[T]) sqrt[T]() &Tensor[T]

sqrt exposes this operation as part of the public API.

fn (Tensor[T]) reciprocal #

fn (t &Tensor[T]) reciprocal[T]() !&Tensor[T]

reciprocal returns the elementwise floating-point reciprocal.

fn (Tensor[T]) tan #

@[inline]
fn (t &Tensor[T]) tan[T]() &Tensor[T]

tan exposes this operation as part of the public API.

fn (Tensor[T]) tanh #

@[inline]
fn (t &Tensor[T]) tanh[T]() &Tensor[T]

tanh exposes this operation as part of the public API.

fn (Tensor[T]) sigmoid #

fn (t &Tensor[T]) sigmoid[T]() &Tensor[T]

sigmoid returns the elementwise logistic function 1 / (1 + exp(-x)). Dense f64 and f32 tensors use the vectorized vsl kernel (<= ~1.4 ulp vs math.*); every other layout or dtype evaluates the formula in f64 per element.

fn (Tensor[T]) trunc #

@[inline]
fn (t &Tensor[T]) trunc[T]() &Tensor[T]

trunc exposes this operation as part of the public API.

fn (Tensor[T]) modf #

fn (t &Tensor[T]) modf[T]() !(&Tensor[T], &Tensor[T])

modf returns fractional and integral parts, in that order, matching NumPy. Only f32 and f64 tensors are supported.

fn (Tensor[T]) frexp #

fn (t &Tensor[T]) frexp[T]() !(&Tensor[T], &Tensor[int])

frexp decomposes each f32/f64 value into a mantissa and base-2 exponent. The mantissa preserves the input floating-point type; exponents use int.

fn (Tensor[T]) signbit #

fn (t &Tensor[T]) signbit[T]() !&Tensor[bool]

signbit returns true for values with a negative sign bit, including -0 and negative NaNs. Signed integers are true when negative; unsigned and boolean values are always false.

fn (Tensor[T]) add #

@[inline]
fn (a &Tensor[T]) add[T](b &Tensor[T]) !&Tensor[T]

add exposes this operation as part of the public API.

fn (Tensor[T]) add_scalar #

@[inline]
fn (a &Tensor[T]) add_scalar[T](scalar T) !&Tensor[T]

add_scalar exposes this operation as part of the public API.

fn (Tensor[T]) subtract #

@[inline]
fn (a &Tensor[T]) subtract[T](b &Tensor[T]) !&Tensor[T]

subtract exposes this operation as part of the public API.

fn (Tensor[T]) subtract_scalar #

@[inline]
fn (a &Tensor[T]) subtract_scalar[T](scalar T) !&Tensor[T]

subtract_scalar exposes this operation as part of the public API.

fn (Tensor[T]) divide #

@[inline]
fn (a &Tensor[T]) divide[T](b &Tensor[T]) !&Tensor[T]

divide exposes this operation as part of the public API.

fn (Tensor[T]) divide_scalar #

@[inline]
fn (a &Tensor[T]) divide_scalar[T](scalar T) !&Tensor[T]

divide_scalar exposes this operation as part of the public API.

fn (Tensor[T]) floor_divide #

fn (a &Tensor[T]) floor_divide[T](b &Tensor[T]) !&Tensor[T]

floor_divide returns elementwise floor(a / b), following NumPy's floor-division rounding for same-dtype real numeric tensors.

fn (Tensor[T]) floor_divide_scalar #

fn (a &Tensor[T]) floor_divide_scalar[T](scalar T) !&Tensor[T]

floor_divide_scalar returns elementwise floor(a / scalar), preserving the tensor dtype and using the same zero-divisor behavior as floor_divide.

fn (Tensor[T]) multiply #

@[inline]
fn (a &Tensor[T]) multiply[T](b &Tensor[T]) !&Tensor[T]

multiply exposes this operation as part of the public API.

fn (Tensor[T]) multiply_scalar #

@[inline]
fn (a &Tensor[T]) multiply_scalar[T](scalar T) !&Tensor[T]

multiply_scalar exposes this operation as part of the public API.

fn (Tensor[T]) + #

@[inline]
fn (a &Tensor[T]) + (b &Tensor[T]) &Tensor[T]
  • adds two tensors elementwise. It panics when their shapes are not broadcastable; use add when shape errors need to be handled explicitly.

fn (Tensor[T]) - #

@[inline]
fn (a &Tensor[T]) - (b &Tensor[T]) &Tensor[T]
  • subtracts two tensors elementwise, following broadcasting rules. It panics when their shapes are not broadcastable; use subtract when shape errors need to be handled explicitly.

fn (Tensor[T]) * #

@[inline]
fn (a &Tensor[T]) * (b &Tensor[T]) &Tensor[T]
  • multiplies two tensors elementwise, following broadcasting rules. It panics when their shapes are not broadcastable; use multiply when shape errors need to be handled explicitly.

fn (Tensor[T]) / #

@[inline]
fn (a &Tensor[T]) / (b &Tensor[T]) &Tensor[T]

/ divides two tensors elementwise, following broadcasting rules. It panics when their shapes are not broadcastable; use divide when shape errors need to be handled explicitly.

fn (Tensor[T]) argmax_axis #

@[inline]
fn (t &Tensor[T]) argmax_axis[T](axis int) !&Tensor[int]

argmax_axis exposes this operation as part of the public API.

fn (Tensor[T]) argmin_axis #

@[inline]
fn (t &Tensor[T]) argmin_axis[T](axis int) !&Tensor[int]

argmin_axis exposes this operation as part of the public API.

fn (Tensor[T]) max_axis #

@[inline]
fn (t &Tensor[T]) max_axis[T](axis int) !&Tensor[T]

max_axis exposes this operation as part of the public API.

fn (Tensor[T]) min_axis #

@[inline]
fn (t &Tensor[T]) min_axis[T](axis int) !&Tensor[T]

min_axis exposes this operation as part of the public API.

fn (Tensor[T]) max_axis_with_keepdims #

fn (t &Tensor[T]) max_axis_with_keepdims[T](axis int, keepdims bool) !&Tensor[T]

max_axis_with_keepdims returns maximum values with the reduced axis optionally retained with length one.

fn (Tensor[T]) min_axis_with_keepdims #

fn (t &Tensor[T]) min_axis_with_keepdims[T](axis int, keepdims bool) !&Tensor[T]

min_axis_with_keepdims returns minimum values with the reduced axis optionally retained with length one.

fn (Tensor[T]) max_axis_squeeze #

fn (t &Tensor[T]) max_axis_squeeze[T](axis int) !&Tensor[T]

max_axis_squeeze returns maximum values with the reduced axis removed, matching NumPy's default keepdims=false shape behavior.

fn (Tensor[T]) min_axis_squeeze #

fn (t &Tensor[T]) min_axis_squeeze[T](axis int) !&Tensor[T]

min_axis_squeeze returns minimum values with the reduced axis removed, matching NumPy's default keepdims=false shape behavior.

fn (Tensor[T]) max_axes #

fn (t &Tensor[T]) max_axes[T](axes []int, keepdims bool) !&Tensor[T]

max_axes reduces several axes by maximum. Negative axes are supported; duplicate axes return an error. An empty axes list returns a copy.

fn (Tensor[T]) min_axes #

fn (t &Tensor[T]) min_axes[T](axes []int, keepdims bool) !&Tensor[T]

min_axes reduces several axes by minimum. Negative axes are supported; duplicate axes return an error. An empty axes list returns a copy.

fn (Tensor[T]) argmax_axis_with_keepdims #

fn (t &Tensor[T]) argmax_axis_with_keepdims[T](axis int, keepdims bool) !&Tensor[int]

argmax_axis_with_keepdims returns maximum indices with optional axis retention.

fn (Tensor[T]) argmin_axis_with_keepdims #

fn (t &Tensor[T]) argmin_axis_with_keepdims[T](axis int, keepdims bool) !&Tensor[int]

argmin_axis_with_keepdims returns minimum indices with optional axis retention.

fn (Tensor[T]) argmax_axis_squeeze #

fn (t &Tensor[T]) argmax_axis_squeeze[T](axis int) !&Tensor[int]

argmax_axis_squeeze returns the maximum indices with the reduced axis removed, matching NumPy's default keepdims=false behavior.

fn (Tensor[T]) argmin_axis_squeeze #

fn (t &Tensor[T]) argmin_axis_squeeze[T](axis int) !&Tensor[int]

argmin_axis_squeeze returns the minimum indices with the reduced axis removed, matching NumPy's default keepdims=false behavior.

fn (Tensor[T]) argmax #

@[inline]
fn (t &Tensor[T]) argmax[T](axis int) !&Tensor[int]

argmax exposes this operation as part of the public API.

fn (Tensor[T]) argmin #

@[inline]
fn (t &Tensor[T]) argmin[T](axis int) !&Tensor[int]

argmin exposes this operation as part of the public API.

fn (Tensor[T]) argmax_flat #

fn (t &Tensor[T]) argmax_flat[T]() !int

argmax_flat returns the flattened index of the first largest value. A NaN value is returned immediately, matching NumPy's argmax behavior.

fn (Tensor[T]) argmin_flat #

fn (t &Tensor[T]) argmin_flat[T]() !int

argmin_flat returns the flattened index of the first smallest value. A NaN value is returned immediately, matching NumPy's argmin behavior.

fn (Tensor[T]) nanargmax #

fn (t &Tensor[T]) nanargmax[T]() !int

nanargmax returns the flattened index of the largest non-NaN value. The first index wins ties, matching NumPy. Empty and all-NaN tensors return an error.

fn (Tensor[T]) nanargmin #

fn (t &Tensor[T]) nanargmin[T]() !int

nanargmin returns the flattened index of the smallest non-NaN value. The first index wins ties, matching NumPy. Empty and all-NaN tensors return an error.

fn (Tensor[T]) argmax_flat_with_keepdims #

fn (t &Tensor[T]) argmax_flat_with_keepdims[T](keepdims bool) !&Tensor[int]

argmax_flat_with_keepdims returns the flattened maximum index as a tensor. When keepdims is true, the tensor retains the input rank with all dimensions set to one; otherwise it is scalar-shaped.

fn (Tensor[T]) argmin_flat_with_keepdims #

fn (t &Tensor[T]) argmin_flat_with_keepdims[T](keepdims bool) !&Tensor[int]

argmin_flat_with_keepdims returns the flattened minimum index as a tensor. When keepdims is true, the tensor retains the input rank with all dimensions set to one; otherwise it is scalar-shaped.

fn (Tensor[T]) nanargmax_flat_with_keepdims #

fn (t &Tensor[T]) nanargmax_flat_with_keepdims[T](keepdims bool) !&Tensor[int]

nanargmax_flat_with_keepdims returns the flattened non-NaN maximum index as a tensor, optionally retaining the input rank with length-one dimensions.

fn (Tensor[T]) nanargmin_flat_with_keepdims #

fn (t &Tensor[T]) nanargmin_flat_with_keepdims[T](keepdims bool) !&Tensor[int]

nanargmin_flat_with_keepdims returns the flattened non-NaN minimum index as a tensor, optionally retaining the input rank with length-one dimensions.

fn (Tensor[T]) nanargmax_axis #

fn (t &Tensor[T]) nanargmax_axis[T](axis int, keepdims bool) !&Tensor[int]

nanargmax_axis returns the index of the largest non-NaN value on axis. Set keepdims to retain the reduced axis as a length-one dimension.

fn (Tensor[T]) nanargmin_axis #

fn (t &Tensor[T]) nanargmin_axis[T](axis int, keepdims bool) !&Tensor[int]

nanargmin_axis returns the index of the smallest non-NaN value on axis. Set keepdims to retain the reduced axis as a length-one dimension.

fn (Tensor[T]) cumsum #

@[direct_array_access; inline]
fn (t &Tensor[T]) cumsum[T](axis int) !&Tensor[T]

cumsum exposes this operation as part of the public API. Axis normalization and shape-derived loop bounds keep the direct array accesses below within the input and output buffers for valid tensors.

fn (Tensor[T]) cumprod #

@[direct_array_access; inline]
fn (t &Tensor[T]) cumprod[T](axis int) !&Tensor[T]

cumprod exposes this operation as part of the public API. Axis normalization and shape-derived loop bounds keep the direct array accesses below within the input and output buffers for valid tensors.

fn (Tensor[T]) cumsum_as #

fn (t &Tensor[T]) cumsum_as[U](axis int) !&Tensor[U]

cumsum_as computes a cumulative sum using an explicitly selected output accumulator type. This is useful when the input type has insufficient precision or range for the running total.

fn (Tensor[T]) cumprod_as #

fn (t &Tensor[T]) cumprod_as[U](axis int) !&Tensor[U]

cumprod_as computes a cumulative product using an explicitly selected output accumulator type.

fn (Tensor[T]) cumsum_flat #

fn (t &Tensor[T]) cumsum_flat[T]() !&Tensor[T]

cumsum_flat computes a cumulative sum over the tensor's logical row-major order and returns a one-dimensional tensor. This is the flattened form of NumPy's cumsum with axis=None.

fn (Tensor[T]) cumsum_flat_as #

fn (t &Tensor[T]) cumsum_flat_as[U]() !&Tensor[U]

cumsum_flat_as computes a flattened cumulative sum with an explicit output accumulator type.

fn (Tensor[T]) cumprod_flat #

fn (t &Tensor[T]) cumprod_flat[T]() !&Tensor[T]

cumprod_flat computes a cumulative product over the tensor's logical row-major order and returns a one-dimensional tensor. This is the flattened form of NumPy's cumprod with axis=None.

fn (Tensor[T]) cumprod_flat_as #

fn (t &Tensor[T]) cumprod_flat_as[U]() !&Tensor[U]

cumprod_flat_as computes a flattened cumulative product with an explicit output accumulator type.

fn (Tensor[T]) nancumsum #

fn (t &Tensor[T]) nancumsum[T](axis int) !&Tensor[T]

nancumsum returns the cumulative sum along an axis, treating NaN inputs as zero while preserving the input element type.

fn (Tensor[T]) nancumsum_as #

fn (t &Tensor[T]) nancumsum_as[U](axis int) !&Tensor[U]

nancumsum_as selects the accumulator and output type for an axis scan.

fn (Tensor[T]) nancumprod #

fn (t &Tensor[T]) nancumprod[T](axis int) !&Tensor[T]

nancumprod returns the cumulative product along an axis, treating NaN inputs as one while preserving the input element type.

fn (Tensor[T]) nancumprod_as #

fn (t &Tensor[T]) nancumprod_as[U](axis int) !&Tensor[U]

nancumprod_as selects the accumulator and output type for an axis scan.

fn (Tensor[T]) nancumsum_flat #

fn (t &Tensor[T]) nancumsum_flat[T]() !&Tensor[T]

nancumsum_flat returns a one-dimensional cumulative sum in logical row-major order, treating NaN inputs as zero.

fn (Tensor[T]) nancumsum_flat_as #

fn (t &Tensor[T]) nancumsum_flat_as[U]() !&Tensor[U]

nancumsum_flat_as selects the accumulator and output type for a flattened NaN-aware cumulative sum.

fn (Tensor[T]) nancumprod_flat #

fn (t &Tensor[T]) nancumprod_flat[T]() !&Tensor[T]

nancumprod_flat returns a one-dimensional cumulative product in logical row-major order, treating NaN inputs as one.

fn (Tensor[T]) nancumprod_flat_as #

fn (t &Tensor[T]) nancumprod_flat_as[U]() !&Tensor[U]

nancumprod_flat_as selects the accumulator and output type for a flattened NaN-aware cumulative product.

fn (Tensor[T]) array_split #

@[direct_array_access]
fn (t &Tensor[T]) array_split[T](ind int, axis int) ![]&Tensor[T]

array_split exposes this operation as part of the public API.

fn (Tensor[T]) array_split_expl #

fn (t &Tensor[T]) array_split_expl[T](ind []int, axis int) ![]&Tensor[T]

array_split_expl splits an array into multiple sub-arrays. Please refer to the split documentation. The only difference between these functions is that array_split allows indices_or_sections to be an integer that does not equally divide the axis. For an array of length l that should be split into n sections, it returns l % n sub-arrays of size l//n + 1 and the rest of size l//n.

fn (Tensor[T]) split #

fn (t &Tensor[T]) split[T](ind int, axis int) ![]&Tensor[T]

split splits an array into multiple sub-arrays. The array will be divided into N equal arrays along axis. If such a split is not possible, panic

fn (Tensor[T]) split_expl #

fn (t &Tensor[T]) split_expl[T](ind []int, axis int) ![]&Tensor[T]

split_expl splits an array into multiple sub-arrays. The array will be divided into The entries of ind indicate where along axis the array is split. For example, [2, 3] would, for axis=0, result in: ary[:2] ary[2:3] ary[3:]

fn (Tensor[T]) hsplit #

fn (t &Tensor[T]) hsplit[T](ind int) ![]&Tensor[T]

hsplit splits an array into multiple sub-arrays horizontally (column-wise). Please refer to the split documentation. hsplit is equivalent to split with axis=1, the array is always split along the second axis regardless of the array dimension.

fn (Tensor[T]) hsplit_expl #

fn (t &Tensor[T]) hsplit_expl[T](ind []int) ![]&Tensor[T]

hsplit_expl splits an array into multiple sub-arrays horizontally (column-wise) Please refer to the split documentation. hsplit is equivalent to split with axis=1, the array is always split along the second axis regardless of the array dimension.

fn (Tensor[T]) vsplit #

fn (t &Tensor[T]) vsplit[T](ind int) ![]&Tensor[T]

vsplit splits an array into multiple sub-arrays vertically (row-wise). Please refer to the split documentation. vsplit is equivalent to split with axis=0 (default), the array is always split along the first axis regardless of the array dimension.

fn (Tensor[T]) vsplit_expl #

fn (t &Tensor[T]) vsplit_expl[T](ind []int) ![]&Tensor[T]

vsplit_expl splits an array into multiple sub-arrays vertically (row-wise). Please refer to the split documentation. vsplit is equivalent to split with axis=0 (default), the array is always split along the first axis regardless of the array dimension.

fn (Tensor[T]) dsplit #

fn (t &Tensor[T]) dsplit[T](ind int) ![]&Tensor[T]

dsplit splits array into multiple sub-arrays along the 3rd axis (depth). Please refer to the split documentation. dsplit is equivalent to split with axis=2, the array is always split along the third axis provided the array dimension is greater than or equal to 3.

fn (Tensor[T]) dsplit_expl #

fn (t &Tensor[T]) dsplit_expl[T](ind []int) ![]&Tensor[T]

dsplit_expl splits array into multiple sub-arrays along the 3rd axis (depth). Please refer to the split documentation. dsplit is equivalent to split with axis=2, the array is always split along the third axis provided the array dimension is greater than or equal to 3.

fn (Tensor[T]) unsqueeze #

fn (t &Tensor[T]) unsqueeze[T](data AxisData) !&Tensor[T]

unsqueeze adds a dimension of size one to a Tensor

fn (Tensor[T]) squeeze #

fn (t &Tensor[T]) squeeze[T](data AxisData) !&Tensor[T]

squeeze removes dimensions of size one from a Tensor. If dim is provided, only that dimension is removed (must be size 1). If no dim is provided, all size-1 dimensions are removed.

fn (Tensor[T]) expand_dims #

fn (t &Tensor[T]) expand_dims[T](data AxisData) !&Tensor[T]

expand_dims adds an axis to a Tensor in order to support broadcasting operations

fn (Tensor[T]) cuda #

fn (t &Tensor[T]) cuda(params CudaParams) !&Tensor[T]

cuda returns an error when CUDA is not enabled at compile time

fn (Tensor[T]) vcl #

fn (t &Tensor[T]) vcl(params VclParams) !&Tensor[T]

vcl returns a VclTensor from a Tensor

fn (Tensor[T]) vulkan #

fn (t &Tensor[T]) vulkan(params storage.VulkanParams) !&Tensor[T]

vulkan exposes this operation as part of the public API.

fn (Tensor[T]) assert_square_matrix #

@[inline]
fn (t &Tensor[T]) assert_square_matrix[T]() !

assert_square_matrix exposes this operation as part of the public API.

fn (Tensor[T]) assert_matrix #

@[inline]
fn (t &Tensor[T]) assert_matrix[T]() !

assert_matrix exposes this operation as part of the public API.

fn (Tensor[T]) ensure_memory #

@[inline]
fn (mut t Tensor[T]) ensure_memory[T]()

ensure_memory exposes this operation as part of the public API.

fn (TensorsIterator[T]) next #

@[inline]
fn (mut its TensorsIterator[T]) next[T]() ?([]T, []int)

next exposes this operation as part of the public API.

fn (VTLRandomPRNG) seed #

fn (mut rng VTLRandomPRNG) seed(seed_data []u32)

seed initializes the PRNG state from two 32-bit seed words.

fn (VTLRandomPRNG) u8 #

@[inline]
fn (mut rng VTLRandomPRNG) u8() u8

u8 returns the next pseudorandom unsigned 8-bit integer.

fn (VTLRandomPRNG) u16 #

@[inline]
fn (mut rng VTLRandomPRNG) u16() u16

u16 returns the next pseudorandom unsigned 16-bit integer.

fn (VTLRandomPRNG) u32 #

@[inline]
fn (mut rng VTLRandomPRNG) u32() u32

u32 returns the next pseudorandom unsigned 32-bit integer.

fn (VTLRandomPRNG) u64 #

@[ignore_overflow; inline]
fn (mut rng VTLRandomPRNG) u64() u64

u64 returns the next pseudorandom unsigned 64-bit integer.

fn (VTLRandomPRNG) block_size #

@[inline]
fn (mut rng VTLRandomPRNG) block_size() int

block_size returns the PRNG output word size in bits.

fn (VTLRandomPRNG) free #

fn (mut rng VTLRandomPRNG) free()

free satisfies the rand.PRNG interface; VTLRandomPRNG holds no heap resources.

enum DType #

enum DType {
	boolean
	int8
	int16
	int32
	int64
	native_int
	uint8
	uint16
	uint32
	uint64
	float32
	float64
	string
	complex128
}

DType describes the element types currently supported by VTL tensors.

enum Device #

enum Device {
	cpu
	cuda
	vulkan
	opencl
}

Device is the backend family used by VTL's device model. It is independent of tensor element type: dtype selection stays a generic type argument.

enum FusedScalarOp #

enum FusedScalarOp {
	add_scalar
	multiply_scalar
}

FusedScalarOp is one scalar arithmetic operation in a fused chain. It lives in vtl so plans, autograd helpers, and nn layers share the same kernel instead of re-implementing scalar walks at each integration point.

enum IndexKind #

enum IndexKind {
	full
	slice
	integer
	array
	ellipsis
	newaxis
}

IndexKind describes one axis operation used by mixed_index.

enum IteratorStrategy #

enum IteratorStrategy {
	flatten_iteration
	strided_iteration
}

IteratorStrategy defines a function to use in order to mutate iteration position

enum MemoryFormat #

enum MemoryFormat {
	row_major
	col_major
}

MemoryFormat is a sum type that lists the possible memory layouts

enum MeshgridIndexing #

enum MeshgridIndexing {
	xy
	ij
}

MeshgridIndexing controls the dimension order used by meshgrid_n.

enum MultiIndexOrder #

enum MultiIndexOrder {
	c
	f
}

MultiIndexOrder selects row-major or column-major flattening order.

enum PadMode #

enum PadMode {
	constant
	edge
	wrap
	reflect
	symmetric
}

PadMode selects how values outside a tensor's bounds are generated.

enum PromotedArithmetic #

enum PromotedArithmetic {
	add
	subtract
	multiply
	divide
	floor_divide
	fmod
	remainder
	power
	float_power
}

PromotedArithmetic identifies the arithmetic operation for promoted dtype selection.

enum PutMode #

enum PutMode {
	raise
	wrap
	clip
}

PutMode controls how flat indices outside a tensor's range are handled.

enum QuantileMethod #

enum QuantileMethod {
	inverted_cdf
	averaged_inverted_cdf
	closest_observation
	interpolated_inverted_cdf
	hazen
	weibull
	linear
	median_unbiased
	normal_unbiased
	lower
	higher
	midpoint
	nearest
}

QuantileMethod selects one of NumPy's thirteen sample-quantile estimators.

enum SearchSide #

enum SearchSide {
	left
	right
}

SearchSide selects which side of equal values receives an insertion index.

enum TakeMode #

enum TakeMode {
	raise
	wrap
	clip
}

TakeMode controls how indices outside a gathered axis are handled.

enum VclOperation #

enum VclOperation {
	add_scalar
	add
	multiply
	gemm
	gemv
	relu
	sigmoid
	linear_forward
	linear_backward
}

VclOperation names the tensor and neural-network operations that callers can request on an OpenCL/VCL device. This lives beside the VCL dispatch so the capability matrix cannot drift from the kernels that actually exist.

struct AxisData #

@[params]
struct AxisData {
pub:
	axis int
}

AxisData defines a public data structure for this module.

struct Chebyshev #

struct Chebyshev {
pub:
	coefficients []f64
	domain       [2]f64
	window       [2]f64
}

Chebyshev stores coefficients in ascending first-kind basis order: coefficients[i] multiplies T_i after mapping domain to window.

fn (Chebyshev) degree #

fn (p Chebyshev) degree() int

degree returns the degree of the Chebyshev series.

fn (Chebyshev) eval #

fn (p Chebyshev) eval(x f64) f64

eval evaluates the Chebyshev series at scalar x using Clenshaw's recurrence.

fn (Chebyshev) eval_tensor #

fn (p Chebyshev) eval_tensor(input &Tensor[f64]) !&Tensor[f64]

eval_tensor evaluates the Chebyshev series elementwise across input.

fn (Chebyshev) to_polynomial #

fn (p Chebyshev) to_polynomial() !Polynomial

to_polynomial converts the Chebyshev series to an equivalent power-series Polynomial.

fn (Chebyshev) derivative #

fn (p Chebyshev) derivative() !Chebyshev

derivative returns the first derivative of the Chebyshev series.

fn (Chebyshev) integral #

fn (p Chebyshev) integral(constant f64) !Chebyshev

integral returns the antiderivative of the Chebyshev series with the given integration constant.

fn (Chebyshev) roots #

fn (p Chebyshev) roots() ![]f64

roots returns the finite real roots of the Chebyshev series in ascending order.

fn (Chebyshev) add #

fn (p Chebyshev) add(other Chebyshev) !Chebyshev

add returns the sum of two Chebyshev series with matching domain and window.

fn (Chebyshev) mul #

fn (p Chebyshev) mul(other Chebyshev) !Chebyshev

mul returns the product of two Chebyshev series with matching domain and window.

struct CreationOptions #

@[params]
struct CreationOptions {
pub:
	device string       = 'cpu'
	memory MemoryFormat = .row_major
}

CreationOptions carries the runtime options shared by the validated root creation helpers. The element type remains a generic type argument, so there is no runtime dtype option.

struct CudaParams #

@[params]
struct CudaParams {}

CudaParams defines a public data structure for this module.

struct DeviceRef #

struct DeviceRef {
	device   Device
	index    int
	explicit bool
}

DeviceRef names a device family and an optional ordinal, matching PyTorch's cuda:0-style strings. Fields are private so every instance has been validated by parse_device; use the accessors to inspect one.

fn (DeviceRef) family #

fn (d &DeviceRef) family() Device

family returns the backend family of the reference.

fn (DeviceRef) ordinal #

fn (d &DeviceRef) ordinal() int

ordinal returns the device index (always 0 for CPU).

fn (DeviceRef) has_explicit_ordinal #

fn (d &DeviceRef) has_explicit_ordinal() bool

has_explicit_ordinal reports whether the index was written in the source string, which name() preserves.

fn (DeviceRef) name #

fn (d &DeviceRef) name() string

name renders the device as a canonical string.

fn (DeviceRef) is_accelerator #

fn (d &DeviceRef) is_accelerator() bool

is_accelerator reports whether the reference names a non-CPU backend.

fn (DeviceRef) compiled #

fn (d &DeviceRef) compiled() bool

compiled reports whether this build includes support for the device family.

fn (DeviceRef) ensure_ordinal #

fn (d &DeviceRef) ensure_ordinal(available int) !

ensure_ordinal checks an ordinal against a runtime device count. It is the part of ensure_available that does not require a live backend, and is useful when a caller already knows how many devices are available.

fn (DeviceRef) ensure_available #

fn (d &DeviceRef) ensure_available() !

ensure_available rejects references to backends that are not compiled in or whose ordinal exceeds the number of devices the runtime reports. Hardware availability is still probed by the backend itself.

struct DiagonalData #

@[params]
struct DiagonalData {
pub:
	offset int
	axis1  int
	axis2  int = 1
}

DiagonalData configures the offset and axes used by diagonal.

struct Hermite #

struct Hermite {
pub:
	coefficients []f64
	domain       [2]f64
	window       [2]f64
}

Hermite stores physicists' Hermite coefficients in ascending basis order.

fn (Hermite) degree #

fn (p Hermite) degree() int

degree returns the degree of the Hermite series.

fn (Hermite) eval #

fn (p Hermite) eval(x f64) f64

eval evaluates the physicists' Hermite series at scalar x.

fn (Hermite) eval_tensor #

fn (p Hermite) eval_tensor(input &Tensor[f64]) !&Tensor[f64]

eval_tensor evaluates the physicists' Hermite series elementwise across input.

fn (Hermite) to_polynomial #

fn (p Hermite) to_polynomial() !Polynomial

to_polynomial converts the physicists' Hermite series to an equivalent power-series Polynomial.

fn (Hermite) derivative #

fn (p Hermite) derivative() !Hermite

derivative returns the first derivative of the physicists' Hermite series.

fn (Hermite) integral #

fn (p Hermite) integral(constant f64) !Hermite

integral returns the antiderivative of the physicists' Hermite series with the given integration constant.

fn (Hermite) roots #

fn (p Hermite) roots() ![]f64

roots returns the finite real roots of the physicists' Hermite series in ascending order.

fn (Hermite) add #

fn (p Hermite) add(other Hermite) !Hermite

add returns the sum of two physicists' Hermite series with matching domain and window.

fn (Hermite) mul #

fn (p Hermite) mul(other Hermite) !Hermite

mul returns the product of two physicists' Hermite series with matching domain and window.

struct HermiteE #

struct HermiteE {
pub:
	coefficients []f64
	domain       [2]f64
	window       [2]f64
}

HermiteE stores probabilists' Hermite coefficients in ascending basis order.

fn (HermiteE) degree #

fn (p HermiteE) degree() int

degree returns the degree of the HermiteE series.

fn (HermiteE) eval #

fn (p HermiteE) eval(x f64) f64

eval evaluates the probabilists' HermiteE series at scalar x.

fn (HermiteE) eval_tensor #

fn (p HermiteE) eval_tensor(input &Tensor[f64]) !&Tensor[f64]

eval_tensor evaluates the probabilists' HermiteE series elementwise across input.

fn (HermiteE) to_polynomial #

fn (p HermiteE) to_polynomial() !Polynomial

to_polynomial converts the probabilists' HermiteE series to an equivalent power-series Polynomial.

fn (HermiteE) derivative #

fn (p HermiteE) derivative() !HermiteE

derivative returns the first derivative of the probabilists' HermiteE series.

fn (HermiteE) integral #

fn (p HermiteE) integral(constant f64) !HermiteE

integral returns the antiderivative of the probabilists' HermiteE series with the given integration constant.

fn (HermiteE) roots #

fn (p HermiteE) roots() ![]f64

roots returns the finite real roots of the probabilists' HermiteE series in ascending order.

fn (HermiteE) add #

fn (p HermiteE) add(other HermiteE) !HermiteE

add returns the sum of two probabilists' HermiteE series with matching domain and window.

fn (HermiteE) mul #

fn (p HermiteE) mul(other HermiteE) !HermiteE

mul returns the product of two probabilists' HermiteE series with matching domain and window.

struct IsCloseData #

@[params]
struct IsCloseData {
pub:
	rtol      f64 = 1e-5
	atol      f64 = 1e-8
	equal_nan bool
}

IsCloseData configures relative and absolute tolerances and NaN comparison.

struct IteratorBuildData #

struct IteratorBuildData[T] {
	next_handler IteratorStrategy
	start        int
}

IteratorBuildData defines a public data structure for this module.

struct Legendre #

struct Legendre {
pub:
	coefficients []f64
	domain       [2]f64
	window       [2]f64
}

Legendre stores coefficients in ascending basis order: coefficients[i] multiplies P_i after mapping domain to window.

fn (Legendre) degree #

fn (p Legendre) degree() int

degree returns the degree of the Legendre series.

fn (Legendre) eval #

fn (p Legendre) eval(x f64) f64

eval evaluates the Legendre series at scalar x.

fn (Legendre) eval_tensor #

fn (p Legendre) eval_tensor(input &Tensor[f64]) !&Tensor[f64]

eval_tensor evaluates the Legendre series elementwise across input.

fn (Legendre) to_polynomial #

fn (p Legendre) to_polynomial() !Polynomial

to_polynomial converts the Legendre series to an equivalent power-series Polynomial.

fn (Legendre) derivative #

fn (p Legendre) derivative() !Legendre

derivative returns the first derivative of the Legendre series.

fn (Legendre) integral #

fn (p Legendre) integral(constant f64) !Legendre

integral returns the antiderivative of the Legendre series with the given integration constant.

fn (Legendre) roots #

fn (p Legendre) roots() ![]f64

roots returns the finite real roots of the Legendre series in ascending order.

fn (Legendre) add #

fn (p Legendre) add(other Legendre) !Legendre

add returns the sum of two Legendre series with matching domain and window.

fn (Legendre) mul #

fn (p Legendre) mul(other Legendre) !Legendre

mul returns the product of two Legendre series with matching domain and window.

struct LinspaceData #

@[params]
struct LinspaceData {
pub:
	endpoint bool         = true
	memory   MemoryFormat = .row_major
}

LinspaceData configures linspace's endpoint and output memory layout.

struct LogspaceData #

@[params]
struct LogspaceData {
pub:
	endpoint bool         = true
	base     f64          = 10.0
	memory   MemoryFormat = .row_major
}

LogspaceData configures logspace's endpoint, base, and output memory layout.

struct MaskedArray #

struct MaskedArray[T] {
pub:
	values &Tensor[T]
	mask   &Tensor[bool]
}

MaskedArray pairs tensor values with a boolean missing-data mask. A true mask entry marks the corresponding value as missing, following NumPy's numpy.ma convention.

struct MaskedValue #

struct MaskedValue[T] {
pub:
	value     T
	is_masked bool
}

MaskedValue carries a reduction result and indicates whether it is masked.

struct MultiIndexOptions #

@[params]
struct MultiIndexOptions {
pub:
	mode       TakeMode = .raise
	axis_modes []TakeMode
	order      MultiIndexOrder = .c
}

MultiIndexOptions configures ravel_multi_index. Set axis_modes to provide a different bounds mode for each coordinate axis; otherwise mode applies to every axis.

struct NanToNumConfig #

@[params]
struct NanToNumConfig {
pub:
	nan    f64
	posinf ?f64
	neginf ?f64
}

NanToNumConfig contains replacement values for non-finite floating-point tensor elements. Missing infinity replacements use the type's finite limits.

struct NormalTensorData #

@[params]
struct NormalTensorData {
	TensorData
	config.NormalConfigStruct
}

NormalTensorData defines a public data structure for this module.

struct Polynomial #

struct Polynomial {
pub:
	coefficients []f64
}

Polynomial stores power-series coefficients in ascending order: coefficients[i] is the coefficient of x^i.

fn (Polynomial) degree #

fn (p Polynomial) degree() int

degree returns the degree of the polynomial.

fn (Polynomial) eval #

fn (p Polynomial) eval(x f64) f64

eval evaluates the polynomial at scalar x using Horner's method.

fn (Polynomial) eval_tensor #

fn (p Polynomial) eval_tensor(input &Tensor[f64]) !&Tensor[f64]

eval_tensor evaluates the polynomial elementwise across input.

fn (Polynomial) add #

fn (p Polynomial) add(other Polynomial) Polynomial

add returns the sum of two polynomials.

fn (Polynomial) mul #

fn (p Polynomial) mul(other Polynomial) Polynomial

mul returns the product of two polynomials.

fn (Polynomial) derivative #

fn (p Polynomial) derivative() Polynomial

derivative returns the first derivative of the polynomial.

fn (Polynomial) integral #

fn (p Polynomial) integral(constant f64) Polynomial

integral returns the antiderivative of the polynomial with the given integration constant.

fn (Polynomial) roots #

fn (p Polynomial) roots() ![]f64

roots returns finite real roots in ascending order, including multiplicity. Complex roots are omitted; non-finite inputs, overflowing evaluations, and numerically ambiguous multiplicities return errors.

struct RandomGenerator #

struct RandomGenerator {
mut:
	rng    &rand.PRNG
	engine &VTLRandomPRNG
}

RandomGenerator owns an independent pseudorandom stream for reproducible experiments that must not modify or depend on V's global random state.

fn (RandomGenerator) free #

fn (mut generator RandomGenerator) free()

free releases the generator's underlying pseudorandom engine.

fn (RandomGenerator) snapshot #

fn (generator &RandomGenerator) snapshot() RandomGeneratorState

snapshot captures the generator's exact raw PRNG state for replay.

fn (RandomGenerator) restore #

fn (mut generator RandomGenerator) restore(state RandomGeneratorState) !

restore replaces this generator's raw PRNG state with a validated snapshot.

fn (RandomGenerator) uniform #

fn (mut generator RandomGenerator) uniform(minimum f64, maximum f64, shape []int) !&Tensor[f64]

uniform returns f64 values in the [minimum, maximum) range.

fn (RandomGenerator) integers #

fn (mut generator RandomGenerator) integers(low int, high int, shape []int) !&Tensor[int]

integers returns seeded int samples from [low, high).

fn (RandomGenerator) integers_with_endpoint #

fn (mut generator RandomGenerator) integers_with_endpoint(low int, high int, shape []int, endpoint bool) !&Tensor[int]

integers_with_endpoint returns seeded int samples from [low, high) or [low, high] when endpoint is true.

fn (RandomGenerator) normal #

fn (mut generator RandomGenerator) normal(shape []int, params NormalTensorData) !&Tensor[f64]

normal returns f64 values from a normal distribution with the given parameters.

fn (RandomGenerator) multivariate_normal #

fn (mut generator RandomGenerator) multivariate_normal(mean &Tensor[f64], covariance &Tensor[f64], sample_shape []int) !&Tensor[f64]

multivariate_normal draws samples with the requested mean and covariance. sample_shape describes the leading sample dimensions; the final output axis contains the variables. Positive-semidefinite covariance matrices are supported, including singular matrices.

fn (RandomGenerator) lognormal #

fn (mut generator RandomGenerator) lognormal(mean f64, sigma f64, shape []int) !&Tensor[f64]

lognormal returns samples whose natural logarithm follows a normal distribution with the given mean and standard deviation.

fn (RandomGenerator) bernoulli #

fn (mut generator RandomGenerator) bernoulli(probability f64, shape []int) !&Tensor[bool]

bernoulli returns bool values sampled with the given probability of true.

fn (RandomGenerator) binomial #

fn (mut generator RandomGenerator) binomial(trials int, probability f64, shape []int) !&Tensor[int]

binomial returns the number of successful trials in each sample using this generator's independent stream.

fn (RandomGenerator) negative_binomial #

fn (mut generator RandomGenerator) negative_binomial(n f64, probability f64, shape []int) !&Tensor[int]

negative_binomial counts failures before n successes using this generator's independent stream. n is the positive real-valued success threshold and p is the success probability for each trial.

fn (RandomGenerator) hypergeometric #

fn (mut generator RandomGenerator) hypergeometric(ngood int, nbad int, nsample int, shape []int) !&Tensor[int]

hypergeometric samples the number of good items in draws made without replacement from a population containing ngood good and nbad bad items.

fn (RandomGenerator) multivariate_hypergeometric #

fn (mut generator RandomGenerator) multivariate_hypergeometric(colors &Tensor[int], nsample int, sample_shape []int) !&Tensor[int]

multivariate_hypergeometric samples category counts without replacement. The final output axis has one count per entry in colors.

fn (RandomGenerator) multinomial #

fn (mut generator RandomGenerator) multinomial(trials int, probabilities &Tensor[f64], sample_shape []int) !&Tensor[int]

multinomial returns category counts for repeated samples from one categorical distribution. The final output axis contains the categories.

fn (RandomGenerator) exponential #

fn (mut generator RandomGenerator) exponential(lambda f64, shape []int) !&Tensor[f64]

exponential returns f64 samples from an exponential distribution with the given positive finite rate using this generator's independent stream.

fn (RandomGenerator) gumbel #

fn (mut generator RandomGenerator) gumbel(location f64, scale f64, shape []int) !&Tensor[f64]

gumbel returns samples from a Gumbel distribution with the given location and non-negative scale using this generator's independent stream.

fn (RandomGenerator) laplace #

fn (mut generator RandomGenerator) laplace(location f64, scale f64, shape []int) !&Tensor[f64]

laplace returns samples from a Laplace distribution with the given location and non-negative scale using this generator's independent stream.

fn (RandomGenerator) cauchy #

fn (mut generator RandomGenerator) cauchy(location f64, scale f64, shape []int) !&Tensor[f64]

cauchy returns samples from a Cauchy distribution with the given location and positive scale using this generator's independent stream.

fn (RandomGenerator) wald #

fn (mut generator RandomGenerator) wald(mean f64, scale f64, shape []int) !&Tensor[f64]

wald returns samples from a Wald (inverse Gaussian) distribution with the given positive mean and positive scale using this generator's stream.

fn (RandomGenerator) logistic #

fn (mut generator RandomGenerator) logistic(location f64, scale f64, shape []int) !&Tensor[f64]

logistic returns samples from a Logistic distribution with the given location and non-negative scale using this generator's independent stream.

fn (RandomGenerator) pareto #

fn (mut generator RandomGenerator) pareto(shape_parameter f64, shape []int) !&Tensor[f64]

pareto returns samples from the standard Pareto distribution (minimum zero) with the given positive shape parameter and this generator's stream.

fn (RandomGenerator) power #

fn (mut generator RandomGenerator) power(shape_parameter f64, shape []int) !&Tensor[f64]

power returns samples from NumPy's power distribution on [0, 1] using the given positive shape parameter and this generator's independent stream.

fn (RandomGenerator) rayleigh #

fn (mut generator RandomGenerator) rayleigh(scale f64, shape []int) !&Tensor[f64]

rayleigh returns samples from a Rayleigh distribution with non-negative scale and this generator's independent stream.

fn (RandomGenerator) vonmises #

fn (mut generator RandomGenerator) vonmises(location f64, concentration f64, shape []int) !&Tensor[f64]

vonmises returns angles in [-pi, pi) from a circular distribution with the given location and non-negative concentration using this generator's stream.

fn (RandomGenerator) triangular #

fn (mut generator RandomGenerator) triangular(left f64, mode f64, right f64, shape []int) !&Tensor[f64]

triangular returns samples from a triangular distribution defined by its left endpoint, mode, right endpoint, and this generator's independent stream.

fn (RandomGenerator) geometric #

fn (mut generator RandomGenerator) geometric(probability f64, shape []int) !&Tensor[int]

geometric returns the number of Bernoulli trials needed for the first success, independently sampled from this generator. Results start at 1.

fn (RandomGenerator) zipf #

fn (mut generator RandomGenerator) zipf(exponent f64, shape []int) !&Tensor[int]

zipf samples positive integers from a Zipf distribution on this generator's independent stream. The exponent must be finite and greater than one.

fn (RandomGenerator) logseries #

fn (mut generator RandomGenerator) logseries(probability f64, shape []int) !&Tensor[int]

logseries samples positive integers from a logarithmic-series distribution.

fn (RandomGenerator) poisson #

fn (mut generator RandomGenerator) poisson(lambda f64, shape []int) !&Tensor[int]

poisson returns integer event counts with the given finite, non-negative expected rate using this generator's independent stream.

fn (RandomGenerator) weibull #

fn (mut generator RandomGenerator) weibull(shape_parameter f64, shape []int) !&Tensor[f64]

weibull returns samples from the unit-scale Weibull distribution. The positive shape parameter controls the distribution's tail and hazard rate.

fn (RandomGenerator) chi_square #

fn (mut generator RandomGenerator) chi_square(degrees_of_freedom f64, shape []int) !&Tensor[f64]

chi_square returns samples from a chi-square distribution with the given positive degrees of freedom.

fn (RandomGenerator) noncentral_chi_square #

fn (mut generator RandomGenerator) noncentral_chi_square(degrees_of_freedom f64, noncentrality f64, shape []int) !&Tensor[f64]

noncentral_chi_square returns samples from a noncentral chi-square distribution using this generator's independent stream.

fn (RandomGenerator) student_t #

fn (mut generator RandomGenerator) student_t(degrees_of_freedom f64, shape []int) !&Tensor[f64]

student_t returns samples from the standard Student's t distribution.

fn (RandomGenerator) f_distribution #

fn (mut generator RandomGenerator) f_distribution(numerator_df f64, denominator_df f64, shape []int) !&Tensor[f64]

f_distribution returns samples from an F distribution with the specified numerator and denominator degrees of freedom.

fn (RandomGenerator) noncentral_f #

fn (mut generator RandomGenerator) noncentral_f(numerator_df f64, denominator_df f64, noncentrality f64, shape []int) !&Tensor[f64]

noncentral_f returns samples from a noncentral F distribution.

fn (RandomGenerator) choice #

fn (mut generator RandomGenerator) choice[T](population &Tensor[T], size int, replace bool) !&Tensor[T]

choice samples values from a tensor's flattened logical order. Without replacement, selected positions are unique; the same value may still occur more than once in the population.

fn (RandomGenerator) choice_weighted #

fn (mut generator RandomGenerator) choice_weighted[T](population &Tensor[T], weights &Tensor[f64], size int, replace bool) !&Tensor[T]

choice_weighted samples values from a tensor's flattened logical order in proportion to non-negative weights. Without replacement, each selected position is removed from the remaining weight distribution.

fn (RandomGenerator) choice_axis #

fn (mut generator RandomGenerator) choice_axis[T](population &Tensor[T], size int, axis int, replace bool) !&Tensor[T]

choice_axis samples complete slices along axis and replaces that axis by size.

fn (RandomGenerator) choice_weighted_axis #

fn (mut generator RandomGenerator) choice_weighted_axis[T](population &Tensor[T], weights &Tensor[f64], size int, axis int, replace bool) !&Tensor[T]

choice_weighted_axis samples complete slices in proportion to non-negative axis weights and replaces that axis by size.

fn (RandomGenerator) permutation #

fn (mut generator RandomGenerator) permutation(size int) !&Tensor[int]

permutation returns the integers in [0, size) in a seeded random order.

fn (RandomGenerator) permutation_tensor #

fn (mut generator RandomGenerator) permutation_tensor[T](input &Tensor[T]) !&Tensor[T]

permutation_tensor returns a copy with rows shuffled along the first axis, matching NumPy's permutation behavior for an N-dimensional array.

fn (RandomGenerator) permutation_axis #

fn (mut generator RandomGenerator) permutation_axis[T](input &Tensor[T], axis int) !&Tensor[T]

permutation_axis returns a copy with slices shuffled along the selected axis. Negative axes are accepted, matching Tensor.take and NumPy's axis convention.

fn (RandomGenerator) gamma #

fn (mut generator RandomGenerator) gamma(alpha f64, scale f64, shape []int) !&Tensor[f64]

gamma returns samples from a Gamma distribution using this generator's independent stream. alpha is the shape and scale is the scale parameter.

fn (RandomGenerator) beta #

fn (mut generator RandomGenerator) beta(alpha f64, beta f64, shape []int) !&Tensor[f64]

beta returns samples from a Beta distribution using this generator's independent stream. alpha and beta are the two positive shape parameters.

fn (RandomGenerator) dirichlet #

fn (mut generator RandomGenerator) dirichlet[T](alpha &Tensor[T], sample_shape []int) !&Tensor[f64]

dirichlet returns samples from a Dirichlet distribution. The final output axes match the concentration tensor's shape; sample_shape is prepended.

struct RandomGeneratorState #

struct RandomGeneratorState {
pub:
	version    int
	state      u64
	bytes_left int
	buffer     u64
}

RandomGeneratorState is a versioned snapshot of an independent random stream.

fn (RandomGeneratorState) serialize #

fn (state RandomGeneratorState) serialize() string

serialize returns a versioned JSON snapshot of the generator state.

struct ReadOnlyDiagonalView #

struct ReadOnlyDiagonalView[T] {
	backing &Tensor[T] = unsafe { nil }
}

ReadOnlyDiagonalView exposes diagonal values without tensor mutators.

struct Tensor #

@[heap]
struct Tensor[T] {
pub mut:
	data    &storage.CpuStorage[T] = unsafe { nil }
	memory  MemoryFormat
	size    int
	shape   []int
	strides []int
}

Tensor defines a public data structure for this module.

struct TensorAxisIterator #

@[heap]
struct TensorAxisIterator[T] {
pub:
	tensor &Tensor[T] = unsafe { nil }
pub mut:
	shape     []int
	strides   []int
	axis      int
	inc       int
	iteration int
	pos       int
}

TensorAxisIterator defines a public data structure for this module.

struct TensorData #

@[params]
struct TensorData {
pub:
	memory MemoryFormat = .row_major
}

TensorData configures the memory layout used by tensor creation functions. The element type is selected through the function's generic type argument.

struct TensorIndex #

struct TensorIndex {
pub:
	kind      IndexKind
	integer   int
	start     int
	stop      int
	has_start bool
	has_stop  bool
	step      int
	indices   &Tensor[int]
}

TensorIndex describes one axis of a mixed basic and advanced indexing operation. Use the constructors below to create valid values.

struct TensorIterator #

@[heap]
struct TensorIterator[T] {
pub:
	tensor       &Tensor[T] = unsafe { nil }
	next_handler IteratorStrategy
pub mut:
	iteration int
}

TensorIterator defines a public data structure for this module.

struct TensorsIterator #

struct TensorsIterator[T] {
mut:
	iters []&TensorIterator[T]
}

TensorsIterator defines a public data structure for this module.

struct TriangularOptions #

@[params]
struct TriangularOptions {
pub:
	k int
}

TriangularOptions selects the diagonal offset for triangular matrix helpers.

struct UniqueAxisResult #

struct UniqueAxisResult[T] {
pub:
	values        &Tensor[T]
	counts        &Tensor[int]
	first_indices &Tensor[int]
	inverse       &Tensor[int]
}

UniqueAxisResult contains unique axis slices and their source metadata.

struct UniqueCounts #

struct UniqueCounts[T] {
pub:
	values &Tensor[T]
	counts &Tensor[int]
}

UniqueCounts contains sorted unique values and their occurrence counts.

struct UnravelIndexOptions #

@[params]
struct UnravelIndexOptions {
pub:
	order MultiIndexOrder = .c
}

UnravelIndexOptions selects the order used by unravel_index. The default is C (row-major) order, matching NumPy.

struct VandermondeData #

@[params]
struct VandermondeData {
pub:
	n          int = -1
	increasing bool
	memory     MemoryFormat = .row_major
}

VandermondeData configures the column count and power order used by vander.

struct VclCapability #

struct VclCapability {
pub:
	operation VclOperation
	dtype     DType
	supported bool
	detail    string
}

VclCapability records whether one operation/DType pair runs on-device.

struct VclParams #

@[params]
struct VclParams {}

VclParams defines a public data structure for this module.