Ancient

 view release on metacpan or  search on metacpan

lib/nvec.pm  view on Meta::CPAN

Return a new vector with elements sorted in ascending order.

=head2 argsort

    my $c = $v->argsort();

Return indices that would sort the vector.

=head1 BOOLEAN REDUCTIONS

=head2 all

    my $bool = $v->all();

True if all elements are non-zero.

=head2 any

    my $bool = $v->any();

True if any element is non-zero.

=head2 count

    my $n = $v->count();

Count of non-zero elements.

=head1 COMPARISON OPERATIONS

These return a new nvec with 1.0 where condition is true, 0.0 otherwise.

=head2 eq, ne

    my $c = $a->eq($b);   # $c[i] = ($a[i] == $b[i]) ? 1 : 0
    my $c = $a->ne($b);   # $c[i] = ($a[i] != $b[i]) ? 1 : 0

Element-wise equality/inequality comparison.

=head2 lt, le, gt, ge

    my $c = $a->lt($b);   # $c[i] = ($a[i] <  $b[i]) ? 1 : 0
    my $c = $a->le($b);   # $c[i] = ($a[i] <= $b[i]) ? 1 : 0
    my $c = $a->gt($b);   # $c[i] = ($a[i] >  $b[i]) ? 1 : 0
    my $c = $a->ge($b);   # $c[i] = ($a[i] >= $b[i]) ? 1 : 0

Element-wise relational comparisons.

=head2 where

    my $c = $v->where($mask);

Select elements where mask is non-zero.

=head1 SPECIAL VALUE CHECKS

=head2 isnan

    my $c = $v->isnan();

Return 1.0 where element is NaN, 0.0 otherwise.

=head2 isinf

    my $c = $v->isinf();

Return 1.0 where element is infinite, 0.0 otherwise.

=head2 isfinite

    my $c = $v->isfinite();

Return 1.0 where element is finite, 0.0 otherwise.

=head1 LINEAR ALGEBRA

=head2 normalize

    my $unit = $v->normalize();

Return unit vector (same direction, norm = 1).

=head2 distance

    my $d = $a->distance($b);

Euclidean distance between two vectors.

=head2 cosine_similarity

    my $sim = $a->cosine_similarity($b);

Cosine similarity (-1 to 1).

=head1 UTILITIES

=head2 simd_info

    my $info = nvec::simd_info();

Return a string describing the SIMD backend in use (e.g., "NEON", "AVX2", "SSE2", "scalar").

=head1 C API FOR XS MODULES

For XS modules that need direct access to nvec's SIMD operations, include
C<nvec_api.h>:

    #include "nvec_api.h"

=head2 Object Lifecycle

    Vec* vec_xs_create(pTHX_ IV capacity);    // Create with capacity
    void vec_xs_destroy(pTHX_ Vec *v);        // Destroy (if not wrapping)
    Vec* vec_xs_from_sv(pTHX_ SV *sv);        // Extract from Perl SV
    SV*  vec_xs_wrap(pTHX_ Vec *v);           // Wrap as Perl object

=head2 Data Access

    double* vec_xs_data(Vec *v);              // Get raw buffer pointer
    IV      vec_xs_len(Vec *v);               // Get length



( run in 0.596 second using v1.01-cache-2.11-cpan-df04353d9ac )