numpy — 0.12.0

org.pycforge.numpy · Author: PyCForge

License: GPL-3.0-only · Created: 2026-10-31

Runtime conversion · Direct declared calls

Function index

absolute · add · argmax · argmin · array · concatenate · copy · divide · dot · full · matmul · matvec · max · mean · min · multiply · negative · ones · reshape · sqrt · subtract · sum · true_divide · vecmat · zeros

Overview

Owned rank-one and rank-two finite float64 arrays, with same-shape matrix addition/subtraction, whole-array and row/column sum/mean, explicit-copy C-order reshape, bounded rank-two matrix multiplication, matrix/vector products, and vector operations.

Using this import

Select Runtime and declare *import numpy as np. Use np.array(values, dtype="float64"). For matching matrices use np.add(a,b) or np.subtract(a,b). Use np.sum(a) for the full total, np.sum(a,axis=0) for column totals and np.mean(a,axis=1) for row averages. Read entries with a[row,col] or tolist(); copy with np.copy(a) or a.copy(). Reshape into independent storage with np.reshape(a, (rows, cols), copy=True); -1 may infer one dimension. Only C order is supported. Multiply matrices of shape (m,k) and (k,n) with np.matmul(a,b); the result has shape (m,n). Use np.matvec(matrix,vector) or np.vecmat(vector,matrix) for independent vector results. These require matching inner dimensions.

Author's limitations

Owned finite float64 vectors and row-major matrices; Runtime only. Constructors, copies, same-shape arithmetic, reductions, explicit-copy reshape and rank-two matmul keep their individual contracts. Assignment shares identity; new results own independent storage. No public views, slicing, matrix iteration/operators or general broadcasting. Multiply an owned finite float64 matrix and vector in the declared order, Runtime only. owned-matvec takes matrix (m,k), vector (k) and returns an independent vector (m); owned-vecmat takes vector (k), matrix (k,n) and returns an independent vector (n). Inner dimensions must match. Each output uses separately rounded binary64 products and a fixed balanced sum tree, split at floor(k/2), left before right. Nearest ties-to-even rounding and gradual underflow are required; no FMA or reassociation. Non-nearest rounding raises RuntimeError. Intermediate product/sum overflow raises OverflowError even before later cancellation. Finite subnormals and underflow are admitted. Empty inner products and zero totals are +0.0. Empty output vectors are valid. Arguments are positional-only and evaluated once in source order. Type/rank errors raise TypeError; mismatched lengths raise ValueError. No scalar/sequence coercion, rank promotion, stacks, broadcasting, views, complex values, @, out or ufunc options. No input mutation or retention. Every failed result rolls back. Checked size, allocation and work exhaustion are fatal. Each output costs one work step plus 2*k-1 tree steps for k>0; no heap scratch or internal collection. Root returned storage across collection. For k>0 let u=2**-53, eta=2**-1074, h=ceil(log2(k)), A=sum(abs(exact products)), gamma(j)=j*u/(1-j*u). Absolute error <= gamma(h+1)*A+(2*k-1)*eta*(1+gamma(h+1)), assuming nearest rounding, gradual underflow and no intermediate overflow. Cancellation may cause large relative error; NumPy/BLAS may accumulate differently, so bitwise equivalence is not promised. Explicit independent copy of an existing owned finite float64 vector or matrix, Runtime only. Matrices of shape (m,n) become row-major (n,m), with result[j,i]=input[i,j]. Vectors keep shape/order but own new storage. Every finite binary64 value, signed zero and subnormal is copied exactly without arithmetic or a rounding-mode requirement. Empty dimensions retain the transposed shape. No axes argument, scalar/sequence coercion, rank promotion, higher ranks or views. The source is positional-only and evaluated once. Type errors are catchable; checked size, allocation and work exhaustion are fatal. One work step per copied element. Every failed result rolls back; inputs and aliases are unchanged and never retained. No internal collection or heap scratch. Root returned storage across collection in the originating context. This is an explicitly named copy operation, not NumPy transpose or .T view semantics. Rank-one arithmetic and reductions retain their separate finite numerical contracts; consult each operation. No NumPy warning/seterr policy or general dtype behavior.

Release notes

Adds matvec and vecmat with independently owned vector results and fixed pairwise accumulation. NumPy transpose view syntax remains unsupported; the SDK supplies a separately named transpose-copy operation. No vector promotion, broadcasting, out or @ syntax. Reference fixtures generated with NumPy 2.5.4.

Examples are author-supplied fixture snapshots. The SDK reports verification for its recorded environment; PyCForge registration does not rerun them.

Conversion contract

Use *import numpy in the module preamble. Each signature states accepted positions, names and defaults. A slash marks positional-only parameters; a star marks keyword-only parameters. Argument expansion, function values and Typed conversion are unsupported.

Owned finite float64 vectors and row-major matrices; Runtime only. Constructors, copies, same-shape arithmetic, reductions, explicit-copy reshape and rank-two matmul keep their individual contracts. Assignment shares identity; new results own independent storage. No public views, slicing, matrix iteration/operators or general broadcasting. Multiply an owned finite float64 matrix and vector in the declared order, Runtime only. owned-matvec takes matrix (m,k), vector (k) and returns an independent vector (m); owned-vecmat takes vector (k), matrix (k,n) and returns an independent vector (n). Inner dimensions must match. Each output uses separately rounded binary64 products and a fixed balanced sum tree, split at floor(k/2), left before right. Nearest ties-to-even rounding and gradual underflow are required; no FMA or reassociation. Non-nearest rounding raises RuntimeError. Intermediate product/sum overflow raises OverflowError even before later cancellation. Finite subnormals and underflow are admitted. Empty inner products and zero totals are +0.0. Empty output vectors are valid. Arguments are positional-only and evaluated once in source order. Type/rank errors raise TypeError; mismatched lengths raise ValueError. No scalar/sequence coercion, rank promotion, stacks, broadcasting, views, complex values, @, out or ufunc options. No input mutation or retention. Every failed result rolls back. Checked size, allocation and work exhaustion are fatal. Each output costs one work step plus 2*k-1 tree steps for k>0; no heap scratch or internal collection. Root returned storage across collection. For k>0 let u=2**-53, eta=2**-1074, h=ceil(log2(k)), A=sum(abs(exact products)), gamma(j)=j*u/(1-j*u). Absolute error <= gamma(h+1)*A+(2*k-1)*eta*(1+gamma(h+1)), assuming nearest rounding, gradual underflow and no intermediate overflow. Cancellation may cause large relative error; NumPy/BLAS may accumulate differently, so bitwise equivalence is not promised. Explicit independent copy of an existing owned finite float64 vector or matrix, Runtime only. Matrices of shape (m,n) become row-major (n,m), with result[j,i]=input[i,j]. Vectors keep shape/order but own new storage. Every finite binary64 value, signed zero and subnormal is copied exactly without arithmetic or a rounding-mode requirement. Empty dimensions retain the transposed shape. No axes argument, scalar/sequence coercion, rank promotion, higher ranks or views. The source is positional-only and evaluated once. Type errors are catchable; checked size, allocation and work exhaustion are fatal. One work step per copied element. Every failed result rolls back; inputs and aliases are unchanged and never retained. No internal collection or heap scratch. Root returned storage across collection in the originating context. This is an explicitly named copy operation, not NumPy transpose or .T view semantics. Other vector operations: Owned contiguous one-dimensional finite float64 arrays, Runtime only. No dtype inference, views, slicing, external buffers, matrices, complex values or general broadcasting. Assignment/arguments share arrays; constructors, copy and arithmetic allocate independent storage. Integer indexing, finite item assignment, len, iteration/reversed, copy()/tolist() and shape/size/ndim are supported. Allocation/work use context budgets; exhaustion is fatal. Ordinary type, shape and bounds errors are catchable. Arrays remain valid in their context until destruction or collection without a live root. Generated C needs no Python/NumPy runtime. Min/max require nonempty arrays and reject mixed-sign zero extrema; argmin/argmax return the first tie. Reduction axis accepts None, integer 0 or -1. No reduction methods, sequence coercion, axis tuples, out, dtype, keepdims, initial or where. Negative/absolute/sqrt return independent arrays; negative square roots are refused. Concatenate accepts a nonempty list/tuple of arrays, including empty arrays; axis=None, 0 or -1. Divide/true_divide and / require an array, equal array lengths and nonzero divisors. Zero divisors raise ValueError; nonfinite results raise OverflowError. In-place /= retains identity/aliases and preserves all elements on failure. Empty division performs no element operations. No floor division or remainder. Sum/mean return independent float64 scalars without array allocation or mutation; a and axis accept positional/named arguments. The fixed sum tree splits at floor(length/2), left then right, rounding each addition to binary64. Mean divides by the exact length (at most 2**53). Empty sum is +0.0; empty mean raises ValueError. Dot(a,b) accepts positional/named arguments evaluated once in source order. Both must be equal-length supported arrays; no scalar/sequence coercion, out, @ or native BLAS. Each binary64 product rounds separately without fused multiply-add, then uses the sum tree. Dot allocates no heap storage, changes/retains neither input and returns an independent scalar. Sum/mean/dot require nearest ties-to-even rounding and gradual underflow. A different rounding mode raises RuntimeError. Any nonfinite intermediate product/sum raises OverflowError even when the mathematical result is finite. Finite subnormals and underflow to zero are permitted. Empty dot and zero totals are +0.0; mean division may produce signed zero. Inputs are preserved on failure, including fatal work exhaustion. For n>0, u=2**-53, eta=2**-1074, h=ceil(log2(n)), gamma(k)=k*u/(1-k*u), and A=sum(abs(exact input)): absolute sum error <= gamma(h)*A+(n-1)*eta*(1+gamma(h)); mean error <= gamma(h+1)*A/n+2*eta*(1+gamma(h+1)). For dot use A=sum(abs(exact a[i]*b[i])): absolute error <= gamma(h+1)*A+(2*n-1)*eta*(1+gamma(h+1)). Bounds assume nearest rounding, gradual underflow and no intermediate overflow. Cancellation can cause large relative error; NumPy/BLAS may accumulate/fuse differently, so bitwise agreement is not promised. NumPy warning/seterr policies are unsupported.

numpy.absolute(x, /) -> array1d-float64

Return each element's absolute value in independent storage; negative zero becomes positive zero.

x: positional-only; required

Return each element's absolute value in independent storage; negative zero becomes positive zero.

Return each element's absolute value in independent storage; negative zero becomes positive zero.

Argument 1: x: See the fixed operation signature and contract.

Returns: A new independent one-dimensional float64 array owned by the Runtime context.

View example: elementwise

numpy.add(x1, x2, /) -> owned-array-float64

Add matching matrices, equal-length vectors, or a vector and scalar into independent storage.

x1: positional-only; required

x2: positional-only; required

Add matching matrices, equal-length vectors, or a vector and scalar into independent storage.

Add matching matrices, equal-length vectors, or a vector and scalar into independent storage.

Argument 1: x1: See the fixed operation signature and contract.

Argument 2: x2: See the fixed operation signature and contract.

Returns: A new independent rank-one or rank-two float64 array.

View example: arithmetic

numpy.argmax(a, axis=None) -> int64

Return the int64 index of the first maximum in a nonempty supported array. Equal values, including signed zeros, keep the first index. axis accepts None, 0 or -1. Empty arrays raise ValueError. No out/keepdims/where/initial, sequence coercion or method form. Min/max reject mixed-sign zero extrema; argmin/argmax keep the first tied index.

a: positional-or-keyword; required

axis: positional-or-keyword; default None

Return the int64 index of the first maximum in a nonempty supported array. Equal values, including signed zeros, keep the first index.

Result must fit signed int64; nonfinite or out-of-range results raise an exception.

Return the int64 index of the first maximum in a nonempty supported array. Equal values, including signed zeros, keep the first index. axis accepts None, 0 or -1. Empty arrays raise ValueError. No out/keepdims/where/initial, sequence coercion or method form. Min/max reject mixed-sign zero extrema; argmin/argmax keep the first tied index.

Argument 1: a: A supported finite float64 array; extrema require at least one element.

Argument 2: axis: None, integer 0 or -1; reductions default to None and concatenate defaults to 0. No axis tuples or booleans.

Returns: An independent int64 scalar; the input array is unchanged.

View example: reductions

numpy.argmin(a, axis=None) -> int64

Return the int64 index of the first minimum in a nonempty supported array. Equal values, including signed zeros, keep the first index. axis accepts None, 0 or -1. Empty arrays raise ValueError. No out/keepdims/where/initial, sequence coercion or method form. Min/max reject mixed-sign zero extrema; argmin/argmax keep the first tied index.

a: positional-or-keyword; required

axis: positional-or-keyword; default None

Return the int64 index of the first minimum in a nonempty supported array. Equal values, including signed zeros, keep the first index.

Result must fit signed int64; nonfinite or out-of-range results raise an exception.

Return the int64 index of the first minimum in a nonempty supported array. Equal values, including signed zeros, keep the first index. axis accepts None, 0 or -1. Empty arrays raise ValueError. No out/keepdims/where/initial, sequence coercion or method form. Min/max reject mixed-sign zero extrema; argmin/argmax keep the first tied index.

Argument 1: a: A supported finite float64 array; extrema require at least one element.

Argument 2: axis: None, integer 0 or -1; reductions default to None and concatenate defaults to 0. No axis tuples or booleans.

Returns: An independent int64 scalar; the input array is unchanged.

View example: reductions

numpy.array(object, dtype) -> owned-array-float64

Copy flat or rectangular nested numeric sequences into independent rank-one or rank-two float64 storage.

object: positional-or-keyword; required

dtype: positional-or-keyword; required

Copy flat or rectangular nested numeric sequences into independent rank-one or rank-two float64 storage.

Copy flat or rectangular nested numeric sequences into independent rank-one or rank-two float64 storage.

Argument 1: object: See the fixed operation signature and contract.

Argument 2: dtype: Float64 string; required unless the signature supplies its default.

Returns: A new independent rank-one or rank-two float64 array.

View example: constructors

numpy.concatenate(arrays, /, axis=0) -> array1d-float64

Join a nonempty list or tuple of supported arrays into independent storage. Empty constituent arrays are allowed. axis accepts None, 0 or -1; no out, dtype or casting overrides.

arrays: positional-only; required

axis: positional-or-keyword; default 0

Join a nonempty list or tuple of supported arrays into independent storage. Empty constituent arrays are allowed. axis accepts None, 0 or -1; no out, dtype or casting overrides.

Join a nonempty list or tuple of supported arrays into independent storage. Empty constituent arrays are allowed. axis accepts None, 0 or -1; no out, dtype or casting overrides.

Argument 1: arrays: See the fixed operation signature and contract.

Argument 2: axis: None, integer 0 or -1; reductions default to None and concatenate defaults to 0. No axis tuples or booleans.

Returns: A new independent one-dimensional float64 array owned by the Runtime context.

View example: concatenation

numpy.copy(a) -> owned-array-float64

Copy an owned rank-one or rank-two array, preserving shape and sharing no data.

a: positional-or-keyword; required

Copy an owned rank-one or rank-two array, preserving shape and sharing no data.

Copy an owned rank-one or rank-two array, preserving shape and sharing no data.

Argument 1: a: A supported finite float64 array; extrema require at least one element.

Returns: A new independent rank-one or rank-two float64 array.

View example: independent-copies

numpy.divide(x1, x2, /) -> array1d-float64

Divide two equal-length float64 arrays, or an array and a numeric scalar, into independent storage. A zero divisor or nonfinite result is outside the finite profile and raises an exception.

x1: positional-only; required

x2: positional-only; required

Divide two equal-length float64 arrays, or an array and a numeric scalar, into independent storage. A zero divisor or nonfinite result is outside the finite profile and raises an exception.

Divide two equal-length float64 arrays, or an array and a numeric scalar, into independent storage. A zero divisor or nonfinite result is outside the finite profile and raises an exception.

Argument 1: x1: See the fixed operation signature and contract.

Argument 2: x2: See the fixed operation signature and contract.

Returns: A new independent one-dimensional float64 array owned by the Runtime context.

View example: elementwise

numpy.dot(a, b) -> float64

Return the finite float64 dot product of two equal-length supported arrays. Each product rounds separately, followed by a fixed balanced pairwise sum. Empty arrays return +0.0; intermediate product or sum overflow raises OverflowError.

a: positional-or-keyword; required

b: positional-or-keyword; required

Return the finite float64 dot product of two equal-length supported arrays. Each product rounds separately, followed by a fixed balanced pairwise sum. Empty arrays return +0.0; intermediate product or sum overflow raises OverflowError.

Return the finite float64 dot product of two equal-length supported arrays. Each product rounds separately, followed by a fixed balanced pairwise sum. Empty arrays return +0.0; intermediate product or sum overflow raises OverflowError.

Argument 1: a: A supported finite float64 array; extrema require at least one element.

Argument 2: b: See the fixed operation signature and contract.

Returns: An independent float64 scalar; the input array is unchanged.

View example: dot-weights

numpy.full(shape, fill_value, dtype) -> owned-array-float64

Create owned rank-one or rank-two float64 storage filled with one finite numeric value.

shape: positional-or-keyword; required

fill_value: positional-or-keyword; required

dtype: positional-or-keyword; required

Create owned rank-one or rank-two float64 storage filled with one finite numeric value.

Create owned rank-one or rank-two float64 storage filled with one finite numeric value.

Argument 1: shape: An integer or one-/two-item integer shape. One -1 may be inferred; counts must match.

Argument 2: fill_value: See the fixed operation signature and contract.

Argument 3: dtype: Float64 string; required unless the signature supplies its default.

Returns: A new independent rank-one or rank-two float64 array.

View example: constructors

numpy.matmul(x1, x2, /) -> owned-array-float64

Multiply two matrices with matching inner dimensions into independent storage using separately rounded products and balanced pairwise accumulation.

x1: positional-only; required

x2: positional-only; required

Multiply two matrices with matching inner dimensions into independent storage using separately rounded products and balanced pairwise accumulation.

Multiply two matrices with matching inner dimensions into independent storage using separately rounded products and balanced pairwise accumulation.

Argument 1: x1: See the fixed operation signature and contract.

Argument 2: x2: See the fixed operation signature and contract.

Returns: An independent row-major float64 matrix of shape (m,n), for inputs (m,k) and (k,n).

View example: arithmetic

numpy.matvec(x1, x2, /) -> array1d-float64

Multiply a matrix by a vector into independent vector storage, using fixed pairwise accumulation.

x1: positional-only; required

x2: positional-only; required

Multiply a matrix by a vector into independent vector storage, using fixed pairwise accumulation.

Multiply a matrix by a vector into independent vector storage, using fixed pairwise accumulation.

Argument 1: x1: See the fixed operation signature and contract.

Argument 2: x2: See the fixed operation signature and contract.

Returns: A new independent one-dimensional float64 array owned by the Runtime context.

View example: arithmetic

numpy.max(a, axis=None) -> float64

Return the maximum finite float64 value of a nonempty supported array, without modifying it or allocating array storage. axis accepts None, 0 or -1. Empty arrays raise ValueError. No out/keepdims/where/initial, sequence coercion or method form. Min/max reject mixed-sign zero extrema; argmin/argmax keep the first tied index.

a: positional-or-keyword; required

axis: positional-or-keyword; default None

Return the maximum finite float64 value of a nonempty supported array, without modifying it or allocating array storage.

Return the maximum finite float64 value of a nonempty supported array, without modifying it or allocating array storage. axis accepts None, 0 or -1. Empty arrays raise ValueError. No out/keepdims/where/initial, sequence coercion or method form. Min/max reject mixed-sign zero extrema; argmin/argmax keep the first tied index.

Argument 1: a: A supported finite float64 array; extrema require at least one element.

Argument 2: axis: None, integer 0 or -1; reductions default to None and concatenate defaults to 0. No axis tuples or booleans.

Returns: An independent float64 scalar; the input array is unchanged.

View example: reductions

numpy.mean(a, axis=None) -> float64-or-array1d-float64

Average a vector or matrix; optionally return independent column or row averages.

a: positional-or-keyword; required

axis: positional-or-keyword; default None

Average a vector or matrix; optionally return independent column or row averages.

Average a vector or matrix; optionally return independent column or row averages.

Argument 1: a: A supported finite float64 vector or matrix. Every required mean slice must be nonempty; zero output slices return an empty vector.

Argument 2: axis: None for all elements; 0/-2 for matrix columns, 1/-1 for matrix rows; vectors allow None/0/-1. No booleans or tuples.

Returns: An independent scalar for vectors or axis=None; an independent context-owned vector for a matrix axis. Empty output is valid; a required empty mean raises ValueError.

View example: sum-mean

numpy.min(a, axis=None) -> float64

Return the minimum finite float64 value of a nonempty supported array, without modifying it or allocating array storage. axis accepts None, 0 or -1. Empty arrays raise ValueError. No out/keepdims/where/initial, sequence coercion or method form. Min/max reject mixed-sign zero extrema; argmin/argmax keep the first tied index.

a: positional-or-keyword; required

axis: positional-or-keyword; default None

Return the minimum finite float64 value of a nonempty supported array, without modifying it or allocating array storage.

Return the minimum finite float64 value of a nonempty supported array, without modifying it or allocating array storage. axis accepts None, 0 or -1. Empty arrays raise ValueError. No out/keepdims/where/initial, sequence coercion or method form. Min/max reject mixed-sign zero extrema; argmin/argmax keep the first tied index.

Argument 1: a: A supported finite float64 array; extrema require at least one element.

Argument 2: axis: None, integer 0 or -1; reductions default to None and concatenate defaults to 0. No axis tuples or booleans.

Returns: An independent float64 scalar; the input array is unchanged.

View example: reductions

numpy.multiply(x1, x2, /) -> array1d-float64

Multiply two equal-length float64 arrays, or an array and a numeric scalar, into new storage.

x1: positional-only; required

x2: positional-only; required

Multiply two equal-length float64 arrays, or an array and a numeric scalar, into new storage.

Multiply two equal-length float64 arrays, or an array and a numeric scalar, into new storage.

Argument 1: x1: See the fixed operation signature and contract.

Argument 2: x2: See the fixed operation signature and contract.

Returns: A new independent one-dimensional float64 array owned by the Runtime context.

View example: arithmetic

numpy.negative(x, /) -> array1d-float64

Negate every element of a supported array into independent storage, preserving IEEE signed-zero negation.

x: positional-only; required

Negate every element of a supported array into independent storage, preserving IEEE signed-zero negation.

Negate every element of a supported array into independent storage, preserving IEEE signed-zero negation.

Argument 1: x: See the fixed operation signature and contract.

Returns: A new independent one-dimensional float64 array owned by the Runtime context.

View example: elementwise

numpy.ones(shape, dtype='float64') -> owned-array-float64

Create owned rank-one or rank-two float64 storage filled with one.

shape: positional-or-keyword; required

dtype: positional-or-keyword; default 'float64'

Create owned rank-one or rank-two float64 storage filled with one.

Create owned rank-one or rank-two float64 storage filled with one.

Argument 1: shape: An integer or one-/two-item integer shape. One -1 may be inferred; counts must match.

Argument 2: dtype: Float64 string; required unless the signature supplies its default.

Returns: A new independent rank-one or rank-two float64 array.

View example: constructors

numpy.reshape(a, /, shape, order='C', *, copy) -> owned-array-float64

Reshape a vector or matrix into new independent storage; explicit copy=True and C order are required.

a: positional-only; required

shape: positional-or-keyword; required

order: positional-or-keyword; default 'C'

copy: keyword-only; required

Reshape a vector or matrix into new independent storage; explicit copy=True and C order are required.

Reshape a vector or matrix into new independent storage; explicit copy=True and C order are required.

Argument 1: a: A supported finite float64 array; extrema require at least one element.

Argument 2: shape: An integer or one-/two-item integer shape. One -1 may be inferred; counts must match.

Argument 3: order: Only the string C (row-major); defaults to C.

Argument 4: copy: Required keyword: True. False, None and non-bools are refused.

Returns: A new independent rank-one or rank-two float64 array.

View example: independent-copies

numpy.sqrt(x, /) -> array1d-float64

Take the square root of each nonnegative element of a supported array into independent storage. Negative elements are outside the finite real profile and raise ValueError.

x: positional-only; required

Take the square root of each nonnegative element of a supported array into independent storage. Negative elements are outside the finite real profile and raise ValueError.

Take the square root of each nonnegative element of a supported array into independent storage. Negative elements are outside the finite real profile and raise ValueError.

Argument 1: x: See the fixed operation signature and contract.

Returns: A new independent one-dimensional float64 array owned by the Runtime context.

View example: elementwise

numpy.subtract(x1, x2, /) -> owned-array-float64

Subtract matching matrices, equal-length vectors, or a vector and scalar into independent storage.

x1: positional-only; required

x2: positional-only; required

Subtract matching matrices, equal-length vectors, or a vector and scalar into independent storage.

Subtract matching matrices, equal-length vectors, or a vector and scalar into independent storage.

Argument 1: x1: See the fixed operation signature and contract.

Argument 2: x2: See the fixed operation signature and contract.

Returns: A new independent rank-one or rank-two float64 array.

View example: arithmetic

numpy.sum(a, axis=None) -> float64-or-array1d-float64

Total a vector or matrix; optionally return independent column or row totals.

a: positional-or-keyword; required

axis: positional-or-keyword; default None

Total a vector or matrix; optionally return independent column or row totals.

Total a vector or matrix; optionally return independent column or row totals.

Argument 1: a: A supported finite float64 vector or matrix. Every required mean slice must be nonempty; zero output slices return an empty vector.

Argument 2: axis: None for all elements; 0/-2 for matrix columns, 1/-1 for matrix rows; vectors allow None/0/-1. No booleans or tuples.

Returns: An independent scalar for vectors or axis=None; an independent context-owned vector for a matrix axis. Empty output is valid; a required empty mean raises ValueError.

View example: sum-mean

numpy.true_divide(x1, x2, /) -> array1d-float64

True-division alias with the same finite array contract as divide. The engine also supports / and identity-preserving /=; failed in-place division leaves the array unchanged.

x1: positional-only; required

x2: positional-only; required

True-division alias with the same finite array contract as divide. The engine also supports / and identity-preserving /=; failed in-place division leaves the array unchanged.

True-division alias with the same finite array contract as divide. The engine also supports / and identity-preserving /=; failed in-place division leaves the array unchanged.

Argument 1: x1: See the fixed operation signature and contract.

Argument 2: x2: See the fixed operation signature and contract.

Returns: A new independent one-dimensional float64 array owned by the Runtime context.

View example: division-forms

numpy.vecmat(x1, x2, /) -> array1d-float64

Multiply a vector by a matrix into independent vector storage, using fixed pairwise accumulation.

x1: positional-only; required

x2: positional-only; required

Multiply a vector by a matrix into independent vector storage, using fixed pairwise accumulation.

Multiply a vector by a matrix into independent vector storage, using fixed pairwise accumulation.

Argument 1: x1: See the fixed operation signature and contract.

Argument 2: x2: See the fixed operation signature and contract.

Returns: A new independent one-dimensional float64 array owned by the Runtime context.

View example: arithmetic

numpy.zeros(shape, dtype='float64') -> owned-array-float64

Create owned rank-one or rank-two float64 storage filled with positive zero.

shape: positional-or-keyword; required

dtype: positional-or-keyword; default 'float64'

Create owned rank-one or rank-two float64 storage filled with positive zero.

Create owned rank-one or rank-two float64 storage filled with positive zero.

Argument 1: shape: An integer or one-/two-item integer shape. One -1 may be inferred; counts must match.

Argument 2: dtype: Float64 string; required unless the signature supplies its default.

Returns: A new independent rank-one or rank-two float64 array.

View example: constructors

Authored fixture examples

Expected output is supplied by the author. Consult verification provenance for the checks performed; conversion-only SDK evidence does not test runtime behavior.

Example: arithmetic

*import numpy as np
def main():
    a=np.array([1, 2, -3], dtype="float64")
    b=np.array([2, -1, 4], dtype="float64")
    print(np.add(a,b).tolist(), np.subtract(a,b).tolist(), np.multiply(a,b).tolist())
    print((a+b).tolist(), (a-b).tolist(), (a*b).tolist())
    print((2+a).tolist(), (2-a).tolist(), (2*a).tolist())
    print((a+2).tolist(), (a-2).tolist(), (a*2).tolist())
    print((-a).tolist(), (+a).tolist())
    a=np.array([[1,2,3],[-4,0,8]],dtype="float64")
    b=np.full((2,3),0.5,dtype="float64")
    c=np.add(a,b)
    print(c.tolist(),np.subtract(a,b).tolist())
    c[0,0]=99
    print(a.tolist(),b.tolist())
    print(np.add(np.zeros((0,3)),np.ones((0,3))).shape)
    print(np.subtract(np.zeros((2,0)),np.ones((2,0))).tolist())
    print(np.add(np.array([[-0.0,5e-324]],dtype="float64"),np.array([[-0.0,5e-324]],dtype="float64")).tolist())
    samples=np.array([[1,2,3],[4,5,6]],dtype="float64")
    weights=np.array([[1,0],[0,1],[1,-1]],dtype="float64")
    product=np.matmul(samples,weights)
    print(product.tolist(),product.shape,np.sum(product,axis=0).tolist())
    product[0,0]=99
    print(samples.tolist(),weights.tolist())
    print(np.matmul(np.zeros((2,0)),np.zeros((0,3))).tolist())
    print(np.matmul(np.zeros((0,2)),np.ones((2,3))).shape)
    a=np.array([[1,2,3],[4,5,6]],dtype="float64")
    x=np.array([1,0,1],dtype="float64")
    w=np.array([2,-1],dtype="float64")
    y=np.matvec(a,x)
    z=np.vecmat(w,a)
    print(y.tolist(),z.tolist())
    y[0]=99
    z[0]=99
    print(a.tolist(),x.tolist(),w.tolist())
    print(np.matvec(np.zeros((2,0)),np.zeros(0)).tolist())
    print(np.vecmat(np.zeros(0),np.zeros((0,3))).tolist())
    print(np.matvec(np.zeros((0,2)),np.zeros(2)).shape)
    print(np.vecmat(np.zeros(2),np.zeros((2,0))).shape)
    return 0

Expected standard output:

[3.0, 1.0, 1.0] [-1.0, 3.0, -7.0] [2.0, -2.0, -12.0]
[3.0, 1.0, 1.0] [-1.0, 3.0, -7.0] [2.0, -2.0, -12.0]
[3.0, 4.0, -1.0] [1.0, 0.0, 5.0] [2.0, 4.0, -6.0]
[3.0, 4.0, -1.0] [-1.0, 0.0, -5.0] [2.0, 4.0, -6.0]
[-1.0, -2.0, 3.0] [1.0, 2.0, -3.0]
[[1.5, 2.5, 3.5], [-3.5, 0.5, 8.5]] [[0.5, 1.5, 2.5], [-4.5, -0.5, 7.5]]
[[1.0, 2.0, 3.0], [-4.0, 0.0, 8.0]] [[0.5, 0.5, 0.5], [0.5, 0.5, 0.5]]
(0, 3)
[[], []]
[[-0.0, 1e-323]]
[[4.0, -1.0], [10.0, -1.0]] (2, 2) [14.0, -2.0]
[[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]] [[1.0, 0.0], [0.0, 1.0], [1.0, -1.0]]
[[0.0, 0.0, 0.0], [0.0, 0.0, 0.0]]
(0, 3)
[4.0, 10.0] [-2.0, -1.0, 0.0]
[[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]] [1.0, 0.0, 1.0] [2.0, -1.0]
[0.0, 0.0]
[0.0, 0.0, 0.0]
(0,)
(0,)

Expected exit code: 0

Example: concatenation

*import numpy as np
def main():
    a=np.array([1,2],dtype="float64")
    b=np.array([-0.0,3],dtype="float64")
    empty=np.zeros(0)
    c=np.concatenate((a,empty,b),axis=-1)
    c[0]=99
    print(c.tolist(),a.tolist(),b.tolist())
    print(np.concatenate([empty],axis=None).tolist())
    print(np.concatenate([a,b]).tolist())
    return 0

Expected standard output:

[99.0, 2.0, -0.0, 3.0] [1.0, 2.0] [-0.0, 3.0]
[]
[1.0, 2.0, -0.0, 3.0]

Expected exit code: 0

Example: constructors

*import numpy as np
def main():
    a=np.array([1, 2.5, True], dtype="float64")
    print(a.tolist(), a.shape, a.size, a.ndim, len(a))
    print(np.zeros(3).tolist(), np.ones((2,)).tolist())
    print(np.full([3], -2, dtype="float64").tolist())
    matrix=np.array([[1,2],[3,4]], dtype="float64")
    print(matrix.shape, matrix.size, matrix.ndim, len(matrix), matrix.tolist())
    cloned=np.copy(matrix)
    alias=matrix
    alias[-1,-1]=8
    print(cloned.tolist(), matrix.tolist(), alias is matrix)
    print(np.zeros((0,3)).shape, np.ones((2,0)).tolist())
    print(np.full((2,2), -0.0, dtype="float64").tolist())
    return 0

Expected standard output:

[1.0, 2.5, 1.0] (3,) 3 1 3
[0.0, 0.0, 0.0] [1.0, 1.0]
[-2.0, -2.0, -2.0]
(2, 2) 4 2 2 [[1.0, 2.0], [3.0, 4.0]]
[[1.0, 2.0], [3.0, 4.0]] [[1.0, 2.0], [3.0, 8.0]] True
(0, 3) [[], []]
[[-0.0, -0.0], [-0.0, -0.0]]

Expected exit code: 0

Example: division-forms

*import numpy as np
def main():
    a=np.array([8, -4, -0.0, 5e-324], dtype="float64")
    b=np.array([2, -2, 4, 1], dtype="float64")
    print(np.divide(a,b).tolist(), np.true_divide(a,b).tolist(), (a/b).tolist())
    print((a/2).tolist(), (2/b).tolist(), (a/True).tolist())
    print(a.tolist(), b.tolist())
    return 0

Expected standard output:

[4.0, 2.0, -0.0, 5e-324] [4.0, 2.0, -0.0, 5e-324] [4.0, 2.0, -0.0, 5e-324]
[4.0, -2.0, -0.0, 0.0] [1.0, -1.0, 0.5, 2.0] [8.0, -4.0, -0.0, 5e-324]
[8.0, -4.0, -0.0, 5e-324] [2.0, -2.0, 4.0, 1.0]

Expected exit code: 0

Example: dot-weights

*import numpy as np
def main():
    a=np.array([2,4,8],dtype="float64")
    b=np.array([0.5,0.25,-0.5],dtype="float64")
    print(float(np.dot(a,b)),float(np.dot(b=b,a=a)))
    print(a.tolist(),b.tolist())
    print(float(np.dot(np.zeros(0),np.zeros(0))))
    print(float(np.dot(np.array([-0.0],dtype="float64"),np.ones(1)))==0.0)
    events=[]
    def mark(name,value):
        events.append(name)
        return value
    a=np.array([2,3],dtype="float64")
    print(float(np.dot(b=mark("right",a),a=mark("left",a))))
    print(events,a.tolist())
    a=np.array([1,2,3],dtype="float64")
    result=float(np.dot(a,a))
    a[0]=99
    print(result,a.tolist())
    return 0

Expected standard output:

-2.0 -2.0
[2.0, 4.0, 8.0] [0.5, 0.25, -0.5]
0.0
True
13.0
['right', 'left'] [2.0, 3.0]
14.0 [99.0, 2.0, 3.0]

Expected exit code: 0

Example: elementwise

*import numpy as np
def main():
    a=np.array([-4, -0.0, 9, 16], dtype="float64")
    print(np.negative(a).tolist())
    print(np.absolute(a).tolist())
    print(np.sqrt(np.absolute(a)).tolist())
    print(np.divide(a,2).tolist())
    print(np.divide(2,np.array([1,2,4,8],dtype="float64")).tolist())
    print(a.tolist())
    return 0

Expected standard output:

[4.0, 0.0, -9.0, -16.0]
[4.0, 0.0, 9.0, 16.0]
[2.0, 0.0, 3.0, 4.0]
[-2.0, -0.0, 4.5, 8.0]
[2.0, 1.0, 0.5, 0.25]
[-4.0, -0.0, 9.0, 16.0]

Expected exit code: 0

Example: independent-copies

*import numpy as np
def main():
    a=np.array([1, 2], "float64")
    b=a
    c=np.copy(a)
    d=np.array(a, dtype="float64")
    e=a.copy()
    b[0]=9
    print(a.tolist(), c.tolist(), d.tolist(), e.tolist(), a is b, a is c)
    a=np.array([[1,2,3],[4,5,6]],dtype="float64")
    b=np.reshape(a, (3,-1), copy=True)
    c=np.reshape(a, -1, copy=True)
    b[0,0]=99
    c[-1]=-9
    print(a.tolist(),b.tolist(),c.tolist())
    print(np.reshape(np.zeros((0,3)),(2,0),copy=True).shape)
    print(np.reshape(np.zeros(0),(-1,3),copy=True).shape)
    def mark(label,value):
        print(label)
        return value
    print(np.reshape(mark('array',a),copy=mark('copy',True),order=mark('order','C'),shape=mark('shape',[1,6])).tolist())
    return 0

Expected standard output:

[9.0, 2.0] [1.0, 2.0] [1.0, 2.0] [1.0, 2.0] True False
[[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]] [[99.0, 2.0], [3.0, 4.0], [5.0, 6.0]] [1.0, 2.0, 3.0, 4.0, 5.0, -9.0]
(2, 0)
(0, 3)
array
copy
order
shape
[[1.0, 2.0, 3.0, 4.0, 5.0, 6.0]]

Expected exit code: 0

Example: reductions

*import numpy as np
def main():
    a=np.array([4, -3, 8, -3, 8], dtype="float64")
    print(np.min(a), np.max(a), np.argmin(a), np.argmax(a))
    print(np.min(a, 0), np.max(a, -1), np.argmin(a, axis=None), np.argmax(a, axis=0))
    print(a.tolist())
    return 0

Expected standard output:

-3.0 8.0 1 2
-3.0 8.0 1 2
[4.0, -3.0, 8.0, -3.0, 8.0]

Expected exit code: 0

Example: sum-mean

*import numpy as np
def main():
    a=np.array([1,2,3,4],dtype="float64")
    print(np.sum(a), np.mean(a))
    print(np.sum(a,0), np.mean(a,-1))
    print(np.sum(a=a,axis=None), np.mean(axis=0,a=a))
    print(a.tolist())
    matrix=np.array([[1,2,3],[4,5,6]],dtype="float64")
    print(float(np.sum(matrix)),float(np.mean(matrix)))
    print(np.sum(matrix,0).tolist(),np.mean(matrix,1).tolist())
    print(np.sum(matrix,-2).tolist(),np.mean(matrix,-1).tolist())
    result=np.sum(matrix,axis=0)
    result[0]=99
    print(matrix.tolist(),result.tolist())
    return 0

Expected standard output:

10.0 2.5
10.0 2.5
10.0 2.5
[1.0, 2.0, 3.0, 4.0]
21.0 3.5
[5.0, 7.0, 9.0] [2.0, 5.0]
[5.0, 7.0, 9.0] [2.0, 5.0]
[[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]] [99.0, 7.0, 9.0]

Expected exit code: 0