| Cyclops Tensor Framework
    parallel arithmetic on multidimensional arrays | 
| Public Member Functions | |
| def | __get__ (self) | 
| def | __get__ (self) | 
| def | __get__ (self) | 
| def | __get__ (self) | 
| def | __get__ (self) | 
| def | __get__ (self) | 
| def | __get__ (self) | 
| def | __get__ (self) | 
| def | __get__ (self) | 
| def | __get__ (self) | 
| def | get_dims (self) | 
| def | get_type (self) | 
| def | __cinit__ (self, lens=None, sp=None, sym=None, dtype=None, order=None, tensor, copy=None) | 
| def | __dealloc__ (self) | 
| def | T (self) | 
| def | transpose (self, axes) | 
| def | __abs__ (self) | 
| def | __nonzero__ (self) | 
| def | __int__ (self) | 
| def | __float__ (self) | 
| def | __neg__ (self) | 
| def | __add__ (self, other) | 
| def | __iadd__ (self, other_in) | 
| def | __mul__ (self, other) | 
| def | __imul__ (self, other_in) | 
| def | __sub__ (self, other) | 
| def | __isub__ (self, other_in) | 
| def | __truediv__ (self, other) | 
| def | __itruediv__ (self, other_in) | 
| def | __div__ (self, other) | 
| def | __idiv__ (self, other_in) | 
| def | __pow__ (self, other, modulus) | 
| def | __matmul__ (self, other) | 
| def | fill_random (self, mn=None, mx=None) | 
| def | fill_sp_random (self, mn=None, mx=None, frac_sp=None) | 
| def | read_from_file (self, path, with_vals=True) | 
| def | write_to_file (self, path, with_vals=True) | 
| def | all (tensor, self, axis=None, out=None, keepdims=None) | 
| def | i (self, string) | 
| def | prnt (self) | 
| def | real (self, tensor, value=None) | 
| def | imag (self, tensor, value=None) | 
| def | copy (self) | 
| def | reshape (self, integer) | 
| def | ravel (self, order="F") | 
| def | read (self, init_inds, vals=None, a=None, b=None) | 
| def | astype (self, dtype, order='F', casting='unsafe') | 
| def | read_local (self) | 
| def | dot (self, other, out=None) | 
| def | tensordot (self, other, axes) | 
| def | read_local_nnz (self) | 
| def | read_all (self, arr=None, unpack=True) | 
| def | write_all (self, arr) | 
| def | conj (self) | 
| def | permute (self, tensor, A, p_A=None, p_B=None, a=None, b=None) | 
| def | write (self, init_inds, init_vals, a=None, b=None) | 
| def | __deepcopy__ (self, memo) | 
| def | __getitem__ (self, key_init) | 
| def | set_zero (self) | 
| def | set_zero (self) | 
| def | set_all (self, value) | 
| def | __setitem__ (self, key_init, value_init) | 
| def | trace (self, offset=0, axis1=0, axis2=1, dtype=None, out=None) | 
| def | diagonal (self, offset=0, axis1=0, axis2=1) | 
| def | sum (self, axis=None, dtype=None, out=None, keepdims=None) | 
| def | norm1 (self) | 
| def | norm2 (self) | 
| def | norm_infty (self) | 
| def | to_nparray (self) | 
| def | __repr__ (self) | 
| def | from_nparray (self, arr) | 
| def | take (self, indices, axis=None, out=None, mode='raise') | 
| def | __richcmp__ (self, b, op) | 
| def | sample (tensor, self, p) | 
| Data Fields | |
| dtype | |
| shape | |
| ndim | |
| order | |
| sp | |
| sym | |
| itemsize | |
| size | |
| nbytes | |
| strides | |
| dt | |
| Static Public Attributes | |
| int | st = 1 | 
| st = self.itemsize | |
| alpha = <char*>self.dt.sr.mulid() | |
| na = np.array([a]) | |
| beta = <char*>self.dt.sr.addid() | |
| nb = np.array([b]) | |
The class for CTF Python tensor.
Attributes
----------
nbytes: int
    The number of bytes for the tensor.
size: int
    Total number of elements in the tensor.
ndim: int
    Number of dimensions.
sp: int
    0 indicates the tensor is not sparse tensor, 1 means the tensor is CTF sparse tensor.
strides: tuple
    Tuple of bytes for each dimension to traverse the tensor.
shape: tuple
    Tuple of each dimension.
dtype: data-type
    Numpy data-type, indicating the type of tensor.
itemsize: int
    One element in bytes.
order: {'F','C'}
    Bytes memory order for the tensor.
sym: ndarray
    ?
Methods
-------
T:
    Transpose of tensor.
all:
    Whether all elements give an axis for a tensor is true.
astype:
    Copy the tensor to specified type.
conj:
    Return the self conjugate tensor element-wisely.
copy:
    Copy the tensor to a new tensor.
diagonal:
    Return the diagonal of the tensor if it is 2D. If the tensor is a higher order square tensor (same shape for every dimension), return diagonal of tensor determined by axis1=0, axis2=1.
dot:
    Return the dot product with tensor other.
fill_random:
    Fill random elements to the tensor.
fill_sp_random:
    Fill random elements to a sparse tensor.
from_nparray:
    Convert numpy ndarray to CTF tensor.
get_dims:
    Return the dims/shape of tensor.
get_type:
    Return the dtype of tensor.
i:
    Core function on summing the ctensor.
imag:
    Return imaginary part of a tensor or set its imaginary part to new value.
norm1:
    1-norm of the tensor.
norm2:
    2-norm of the tensor.
norm_infty:
    Infinity-norm of the tensor.
permute:
    Permute the tensor.
prnt:
    Function to print the non-zero elements and their indices of a tensor.
ravel:
    Return the flattened tensor.
read:
    Helper function on reading a tensor.
read_all:
    Helper function on reading a tensor.
read_local:
    Helper function on reading a tensor.
read_local_nnz:
    Helper function on reading a tensor.
real:
    Return real part of a tensor or set its real part to new value.
reshape:
    Return a new tensor with reshaped shape.
sample:
    Extract a sample of the entries (if sparse of the current nonzeros) by keeping each entry with probability p. Also transforms tensor into sparse format if not already.
set_all:
    Set all elements in a tensor to a value.
set_zero:
    Set all elements in a tensor to 0.
sum:
    Sum of elements in tensor or along specified axis.
take:
    Take elements from a tensor along axis.
tensordot:
    Return the tensor dot product of two tensors along axes.
to_nparray:
    Convert the tensor to numpy array.
trace:
    Return the sum over the diagonal of the tensor.
transpose:
    Return the transposed tensor with specified order of axes.
write:
    Helper function on writing a tensor.
write_all:
    Helper function on writing a tensor.
 
| def ctf.core.tensor.__abs__ | ( | self | ) | 
Definition at line 991 of file core.pyx.
References ctf.core.abs().
| def ctf.core.tensor.__cinit__ | ( | self, | |
| lens = None, | |||
| sp = None, | |||
| sym = None, | |||
| dtype = None, | |||
| order = None, | |||
| tensor, | |||
| copy = None | |||
| ) | 
Definition at line 754 of file core.pyx.
References ctf.core.astensor().
Referenced by ctf.core.tensor.real().
| def ctf.core.tensor.__dealloc__ | ( | self | ) | 
Definition at line 872 of file core.pyx.
References ctf.core.tensor.dt.
| def ctf.core.tensor.__deepcopy__ | ( | self, | |
| memo | |||
| ) | 
Definition at line 2343 of file core.pyx.
References ctf.core.tensor.shape.
| def ctf.core.tensor.__float__ | ( | self | ) | 
Definition at line 1007 of file core.pyx.
References ctf.core.tensor.shape, CTF_int::distribution.size, CTF_int::offload_tsr.size, CTF_int::tensor.size, ctf.core.tensor.size, and ctf.core.tensor.to_nparray().
| def ctf.core.tensor.__get__ | ( | self | ) | 
Definition at line 654 of file core.pyx.
References ctf.core.tensor.strides.
Referenced by ctf.core.tensor.__get__().
| def ctf.core.tensor.__get__ | ( | self | ) | 
Definition at line 661 of file core.pyx.
References ctf.core.tensor.__get__(), CTF_int::offload_arr.nbytes, and ctf.core.tensor.nbytes.
| def ctf.core.tensor.__get__ | ( | self | ) | 
Definition at line 668 of file core.pyx.
References ctf.core.tensor.__get__(), and ctf.core.tensor.itemsize.
| def ctf.core.tensor.__get__ | ( | self | ) | 
Definition at line 675 of file core.pyx.
References ctf.core.tensor.__get__(), CTF_int::distribution.size, CTF_int::offload_tsr.size, CTF_int::tensor.size, and ctf.core.tensor.size.
| def ctf.core.tensor.__get__ | ( | self | ) | 
Definition at line 682 of file core.pyx.
References ctf.core.tensor.__get__(), and ctf.core.tensor.ndim.
| def ctf.core.tensor.__get__ | ( | self | ) | 
Definition at line 689 of file core.pyx.
References ctf.core.tensor.__get__(), and ctf.core.tensor.shape.
| def ctf.core.tensor.__get__ | ( | self | ) | 
Definition at line 696 of file core.pyx.
References ctf.core.tensor.__get__(), and ctf.core.tensor.dtype.
| def ctf.core.tensor.__get__ | ( | self | ) | 
Definition at line 703 of file core.pyx.
References ctf.core.tensor.__get__(), CTF_int::topology.order, CTF::Partition.order, CTF_int::strp_tsr.order, CTF_int::distribution.order, CTF_int::seq_tsr_scl.order, CTF_int::tensor.order, CTF_int::tspsum_permute.order, CTF_int::spctr_pin_keys.order, CTF_int::tspsum_pin_keys.order, and ctf.core.tensor.order.
| def ctf.core.tensor.__get__ | ( | self | ) | 
Definition at line 710 of file core.pyx.
References ctf.core.tensor.__get__(), and ctf.core.tensor.sp.
| def ctf.core.tensor.__get__ | ( | self | ) | 
Definition at line 717 of file core.pyx.
References ctf.core.tensor.__get__(), ctf.core.conv_type(), ctf.core.tensor.dt, ctf.core.tensor.dtype, CTF_int.sum_bool_tsr(), CTF_int::seq_tsr_scl.sym, CTF_int::tensor.sym, and ctf.core.tensor.sym.
| def ctf.core.tensor.__getitem__ | ( | self, | |
| key_init | |||
| ) | 
Definition at line 2348 of file core.pyx.
References ctf.core.tensor._get_slice(), ctf.core.tensor.dtype, ctf.core.tensor.ndim, CTF::Partition.order, CTF_int::topology.order, CTF_int::strp_tsr.order, CTF_int::distribution.order, CTF_int::seq_tsr_scl.order, CTF_int::tensor.order, CTF_int::tspsum_permute.order, CTF_int::spctr_pin_keys.order, CTF_int::tspsum_pin_keys.order, ctf.core.tensor.order, CTF::Sparse_Tensor< dtype >.read(), CTF::Tensor< dtype >.read(), CTF_int::tensor.read(), CTF_int::ConstPairIterator.read(), CTF_int::PairIterator.read(), ctf.core.tensor.read(), ctf.core.tensor.reshape(), and ctf.core.tensor.sp.
| def ctf.core.tensor.__iadd__ | ( | self, | |
| other_in | |||
| ) | 
Definition at line 1032 of file core.pyx.
References ctf.core.tensor._ufunc_interpret(), ctf.core.astensor(), ctf.core.tensor.dtype, CTF_int::int1.i, CTF_int::int2.i, CTF::Tensor< dtype >.i(), ctf.core.tensor.i(), and ctf.core.tensor.ndim.
| def ctf.core.tensor.__idiv__ | ( | self, | |
| other_in | |||
| ) | 
Definition at line 1111 of file core.pyx.
References ctf.core.tensor._ufunc_interpret(), ctf.core.astensor(), ctf.core.tensor.dtype, CTF_int::int1.i, CTF_int::int2.i, CTF::Tensor< dtype >.i(), ctf.core.tensor.i(), ctf.core.tensor.ndim, CTF_int::offload_tsr.set_zero(), CTF_int::tensor.set_zero(), and ctf.core.tensor.set_zero().
| def ctf.core.tensor.__imul__ | ( | self, | |
| other_in | |||
| ) | 
Definition at line 1054 of file core.pyx.
References ctf.core.tensor._ufunc_interpret(), ctf.core.astensor(), ctf.core.tensor.dtype, CTF_int::int1.i, CTF_int::int2.i, CTF::Tensor< dtype >.i(), ctf.core.tensor.i(), ctf.core.tensor.ndim, CTF_int::offload_tsr.set_zero(), CTF_int::tensor.set_zero(), and ctf.core.tensor.set_zero().
| def ctf.core.tensor.__int__ | ( | self | ) | 
Definition at line 1002 of file core.pyx.
References ctf.core.tensor.shape, CTF_int::distribution.size, CTF_int::offload_tsr.size, CTF_int::tensor.size, ctf.core.tensor.size, and ctf.core.tensor.to_nparray().
| def ctf.core.tensor.__isub__ | ( | self, | |
| other_in | |||
| ) | 
Definition at line 1074 of file core.pyx.
References ctf.core.tensor._ufunc_interpret(), ctf.core.astensor(), ctf.core.tensor.dtype, CTF_int::int1.i, CTF_int::int2.i, CTF::Tensor< dtype >.i(), ctf.core.tensor.i(), and ctf.core.tensor.ndim.
| def ctf.core.tensor.__itruediv__ | ( | self, | |
| other_in | |||
| ) | 
Definition at line 1091 of file core.pyx.
References ctf.core.tensor._ufunc_interpret(), ctf.core.astensor(), ctf.core.tensor.dtype, CTF_int::int1.i, CTF_int::int2.i, CTF::Tensor< dtype >.i(), ctf.core.tensor.i(), ctf.core.tensor.ndim, CTF_int::offload_tsr.set_zero(), CTF_int::tensor.set_zero(), and ctf.core.tensor.set_zero().
| def ctf.core.tensor.__matmul__ | ( | self, | |
| other | |||
| ) | 
Definition at line 1172 of file core.pyx.
References ctf.core.tensor.dot().
| def ctf.core.tensor.__neg__ | ( | self | ) | 
Definition at line 1016 of file core.pyx.
References ctf.core.astensor(), and ctf.core.tensor.dtype.
| def ctf.core.tensor.__nonzero__ | ( | self | ) | 
Definition at line 994 of file core.pyx.
References ctf.core.tensor.shape, CTF_int::distribution.size, CTF_int::offload_tsr.size, CTF_int::tensor.size, ctf.core.tensor.size, and ctf.core.tensor.to_nparray().
| def ctf.core.tensor.__pow__ | ( | self, | |
| other, | |||
| modulus | |||
| ) | 
Definition at line 1138 of file core.pyx.
References ctf.core.tensor.dt, ctf.core.tensor.dtype, and ctf.core.power().
| def ctf.core.tensor.__repr__ | ( | self | ) | 
Definition at line 2679 of file core.pyx.
References ctf.core.tensor.to_nparray().
| def ctf.core.tensor.__richcmp__ | ( | self, | |
| b, | |||
| op | |||
| ) | 
Definition at line 2750 of file core.pyx.
References ctf.core.tensor._compare_tensors(), ctf.core.astensor(), and ctf.core.tensor.dtype.
| def ctf.core.tensor.__setitem__ | ( | self, | |
| key_init, | |||
| value_init | |||
| ) | 
Definition at line 2422 of file core.pyx.
References ctf.core.tensor._write_slice(), ctf.core.astensor(), ctf.core.tensor.dtype, ctf.core.tensor.ndim, CTF::Partition.order, CTF_int::topology.order, CTF_int::strp_tsr.order, CTF_int::distribution.order, CTF_int::seq_tsr_scl.order, CTF_int::tensor.order, CTF_int::tspsum_permute.order, CTF_int::spctr_pin_keys.order, CTF_int::tspsum_pin_keys.order, ctf.core.tensor.order, CTF_int::ConstPairIterator.permute(), CTF_int::tensor.permute(), CTF::Tensor< dtype >.permute(), ctf.core.tensor.permute(), ctf.core.tensor.set_all(), CTF_int::offload_tsr.set_zero(), CTF_int::tensor.set_zero(), ctf.core.tensor.set_zero(), CTF::Sparse_Tensor< dtype >.write(), CTF_int::tensor.write(), CTF::Tensor< dtype >.write(), CTF_int::PairIterator.write(), and ctf.core.tensor.write().
| def ctf.core.tensor.all | ( | tensor, | |
| self, | |||
| axis = None, | |||
| out = None, | |||
| keepdims = None | |||
| ) | 
all(axis=None, out=None, keepdims = False)
Return whether given an axis elements are True.
Parameters
----------
axis: None or int, optional
    Currently not supported in CTF Python.
out: tensor, optional
    Currently not supported in CTF Python.
keepdims : bool, optional
    Currently not supported in CTF Python.
Returns
-------
output: tensor_like
    Output tensor or scalar.
See Also
--------
ctf: ctf.all
Examples
--------
>>> import ctf
>>> a = ctf.astensor([[0, 1], [1, 1]])
>>> a.all()
False
 
Definition at line 1348 of file core.pyx.
References ctf.core.tensor.dt, ctf.core.tensor.dtype, ctf.core.tensor.ndim, ctf.core.tensor.reshape(), and ctf.core.tensor.shape.
| def ctf.core.tensor.astype | ( | self, | |
| dtype, | |||
| order = 'F', | |||
| casting = 'unsafe' | |||
| ) | 
astype(dtype, order='F', casting='unsafe')
Copy the tensor to specified type.
Parameters
----------
dtype: data-type
    Numpy data-type.
order: {'F', 'C'}
    Bytes order for the tensor.
casting: {‘no’, ‘equiv’, ‘safe’, ‘same_kind’, ‘unsafe’}, optional
    Control the casting. Please refer to numpy.ndarray.astype, please refer to numpy.ndarray.astype for more information.
Returns
-------
output: tensor
    Copied tensor with specified data-type.
See Also
--------
numpy: numpy.ndarray.astype
Examples
--------
>>> import ctf
>>> a = ctf.astensor([[1,2,3], [4,5,6], [7,8,9]])
>>> a.dtype
<class 'numpy.int64'>
>>> a.astype(np.float64).dtype
<class 'numpy.float64'>
 
Definition at line 1861 of file core.pyx.
References ctf.core.tensor._convert_type(), ctf.core.tensor.astype(), CTF_int::algstrct.copy(), CTF::Set< dtype, is_ord >.copy(), ctf.core.tensor.copy(), ctf.core.tensor.dtype, ctf.core.tensor.itemsize, and ctf.core.tensor.shape.
Referenced by ctf.core.tensor.astype().
| def ctf.core.tensor.conj | ( | self | ) | 
conj()
Return the self conjugate tensor element-wisely.
Returns
-------
output: tensor
    The element-wise complex conjugate of the tensor. If the tensor is not complex, just return a copy.
Examples
--------
>>> import ctf
>>> a = ctf.astensor([2+3j, 3-2j])
>>> a
array([2.+3.j, 3.-2.j])
>>> a.conj()
array([2.-3.j, 3.+2.j])
 
| def ctf.core.tensor.copy | ( | self | ) | 
copy()
Copy the tensor to a new tensor.
Returns
-------
output: tensor_like
    Output copied tensor.
Examples
--------
>>> import ctf
>>> a = ctf.astensor([[1,2,3],[4,5,6]])
>>> b = a.copy()
>>> id(a) == id(b)
False
>>> a == b
array([[ True,  True,  True],
       [ True,  True,  True]])
 
Definition at line 1688 of file core.pyx.
References ctf.core.tensor.dtype, and ctf.core.tensor.shape.
Referenced by ctf.core.tensor.astype(), and ctf.core.tensor.real().
| def ctf.core.tensor.diagonal | ( | self, | |
| offset = 0, | |||
| axis1 = 0, | |||
| axis2 = 1 | |||
| ) | 
diagonal(offset=0, axis1=0, axis2=1)
Return the diagonal of the tensor if it is 2D. If the tensor is a higher order square tensor (same shape for every dimension), return diagonal of tensor determined by axis1=0, axis2=1.
Parameters
----------
offset: int, optional
    Default is 0 which indicates the main diagonal.
axis1: int, optional
    Default is 0 which indicates the first axis of 2-D tensor where diagonal is taken.
axis2: int, optional
    Default is 1 which indicates the second axis of 2-D tensor where diagonal is taken.
Returns
-------
output: tensor
    Diagonal of input tensor.
Notes
-----
`ctf.diagonal` only supports diagonal of square tensor with order more than 2.
Examples
--------
>>> import ctf
>>> a = ctf.astensor([[1,2,3], [4,5,6], [7,8,9]])
>>> a.diagonal()
array([1, 5, 9])
 
| def ctf.core.tensor.dot | ( | self, | |
| other, | |||
| out = None | |||
| ) | 
dot(other, out=None)
Return the dot product with tensor other.
Parameters
----------
other: tensor_like
    The other input tensor.
out: tensor
    Currently not supported in CTF Python.
Returns
-------
output: tensor
    Dot product of two tensors.
See Also
--------
numpy: numpy.dot()
ctf: ctf.dot()
Examples
--------
>>> import ctf
>>> a = ctf.astensor([[1,2,3], [4,5,6], [7,8,9]])
>>> b = ctf.astensor([1,1,1])
>>> a.dot(b)
array([ 6, 15, 24])
 
Definition at line 1989 of file core.pyx.
Referenced by ctf.core.tensor.__matmul__().
| def ctf.core.tensor.fill_random | ( | self, | |
| mn = None, | |||
| mx = None | |||
| ) | 
tensor.fill_random(mn=None, mx=None)
Fill random elements to the tensor.
Parameters
----------
mn: int or float
    The range of random number from, default 0.
mx: int or float
    The range of random number to, default 1.
See Also
--------
ctf: ctf.tensor.fill_sp_random()
Examples
--------
>>> import ctf
>>> a = ctf.zeros([2, 2])
>>> a
    array([[0., 0.],
   [0., 0.]])
>>> a.fill_random(3,5)
>>> a
    array([[3.31908598, 4.34013067],
   [4.5355426 , 4.6763659 ]])
 
Definition at line 1177 of file core.pyx.
References ctf.core.tensor.dt, and ctf.core.tensor.dtype.
| def ctf.core.tensor.fill_sp_random | ( | self, | |
| mn = None, | |||
| mx = None, | |||
| frac_sp = None | |||
| ) | 
tensor.fill_sp_random(mn=None, mx=None, frac_sp=None)
Fill random elements to a sparse tensor.
Parameters
----------
mn: int or float
    The range of random number from, default 0.
mx: int or float
    The range of random number to, default 1.
frac_sp: float
    The percent of non-zero elements.
See Also
--------
ctf: ctf.tensor.fill_random()
Examples
--------
>>> import ctf
>>> a = ctf.tensor([3, 3], sp=1)
>>> a.fill_sp_random(frac_sp=0.2)
>>> a
array([[0.96985989, 0.        , 0.        ],
       [0.        , 0.        , 0.10310342],
       [0.        , 0.        , 0.        ]])
 
Definition at line 1221 of file core.pyx.
References ctf.core.tensor.dt, and ctf.core.tensor.dtype.
| def ctf.core.tensor.from_nparray | ( | self, | |
| arr | |||
| ) | 
from_nparray(arr)
Convert numpy ndarray to CTF tensor.
Returns
-------
output: tensor
    CTF tensor of the numpy ndarray.
Examples
--------
>>> import ctf
>>> import numpy as np
>>> a = np.asarray([1.,2.,3.])
>>> b = ctf.zeros([3, ])
>>> b.from_nparray(a)
>>> b
array([1., 2., 3.])
 
Definition at line 2682 of file core.pyx.
References ctf.core.tensor._tot_size(), ctf.core.tensor.dtype, CTF::Sparse_Tensor< dtype >.write(), CTF_int::tensor.write(), CTF::Tensor< dtype >.write(), CTF_int::PairIterator.write(), ctf.core.tensor.write(), and ctf.core.tensor.write_all().
| def ctf.core.tensor.get_dims | ( | self | ) | 
tensor.get_dims()
Return the dims/shape of tensor.
Returns
-------
output: tuple
    Dims or shape of the tensor. 
Definition at line 728 of file core.pyx.
References ctf.core.tensor.shape.
| def ctf.core.tensor.get_type | ( | self | ) | 
tensor.get_type()
Return the dtype of tensor.
Returns
-------
output: data-type
    Dtype of the tensor. 
Definition at line 741 of file core.pyx.
References ctf.core.tensor.dtype.
| def ctf.core.tensor.i | ( | self, | |
| string | |||
| ) | 
i(string)
Core function on summing the ctensor.
Parameters
----------
string: string
    Dimensions for summation.
Returns
-------
output: tensor_like
    Output tensor or scalar.
Examples
--------
>>> import ctf
>>> a = ctf.astensor([[1,2,3],[4,5,6]])
>>> a.i("ij") << a.i("ij")
>>> a
array([[ 2,  4,  6],
       [ 8, 10, 12]])
 
Definition at line 1549 of file core.pyx.
References CTF::Partition.order, CTF_int::topology.order, CTF_int::strp_tsr.order, CTF_int::distribution.order, CTF_int::seq_tsr_scl.order, CTF_int::tensor.order, CTF_int::tspsum_permute.order, CTF_int::spctr_pin_keys.order, CTF_int::tspsum_pin_keys.order, and ctf.core.tensor.order.
Referenced by ctf.core.tensor.__iadd__(), ctf.core.tensor.__idiv__(), ctf.core.tensor.__imul__(), ctf.core.tensor.__isub__(), ctf.core.tensor.__itruediv__(), and ctf.core.tensor.set_zero().
| def ctf.core.tensor.imag | ( | self, | |
| tensor, | |||
| value = None | |||
| ) | 
imag(value = None)
Return imaginary part of a tensor or set its imaginary part to new value.
Returns
-------
value: tensor_like
    The value tensor set imaginary to the original tensor, current only support value tensor with dtype `np.float64` or `np.complex128`. Default is none.
See Also
--------
ctf: ctf.reshape()
Examples
--------
>>> import ctf
>>> a = ctf.astensor([1+2j, 3+4j])
>>> b = ctf.astensor([5,6], dtype=np.float64)
>>> a.imag(value = b)
>>> a
array([5.+2.j, 6.+4.j])
 
Definition at line 1640 of file core.pyx.
References ctf.core.tensor.dt, ctf.core.tensor.dtype, ctf.core.tensor.shape, and ctf.core.zeros().
| def ctf.core.tensor.norm1 | ( | self | ) | 
norm1()
1-norm of the tensor.
Returns
-------
output: scalar
    1-norm of the tensor.
Examples
--------
>>> import ctf
>>> a = ctf.ones([3,4], dtype=np.float64)
>>> a.norm1()
12.0
 
Definition at line 2570 of file core.pyx.
References ctf.core.tensor.dt, and ctf.core.tensor.dtype.
| def ctf.core.tensor.norm2 | ( | self | ) | 
norm2()
2-norm of the tensor.
Returns
-------
output: scalar
    2-norm of the tensor.
Examples
--------
>>> import ctf
>>> a = ctf.ones([3,4], dtype=np.float64)
>>> a.norm2()
3.4641016151377544
 
Definition at line 2594 of file core.pyx.
References ctf.core.tensor.dt, and ctf.core.tensor.dtype.
| def ctf.core.tensor.norm_infty | ( | self | ) | 
norm_infty()
Infinity norm of the tensor.
Returns
-------
output: scalar
    Infinity norm of the tensor.
Examples
--------
>>> import ctf
>>> a = ctf.ones([3,4], dtype=np.float64)
>>> a.norm_infty()
1.0
 
Definition at line 2628 of file core.pyx.
References ctf.core.tensor.dt, and ctf.core.tensor.dtype.
| def ctf.core.tensor.permute | ( | self, | |
| tensor, | |||
| A, | |||
| p_A = None, | |||
| p_B = None, | |||
| a = None, | |||
| b = None | |||
| ) | 
permute(self, tensor A, p_A=None, p_B=None, a=None, b=None) Permute the tensor.
Definition at line 2144 of file core.pyx.
References ctf.core.tensor.dtype, ctf.core.tensor.ndim, CTF_int::topology.order, CTF::Partition.order, CTF_int::strp_tsr.order, CTF_int::distribution.order, CTF_int::seq_tsr_scl.order, CTF_int::tensor.order, CTF_int::tspsum_permute.order, CTF_int::spctr_pin_keys.order, CTF_int::tspsum_pin_keys.order, ctf.core.tensor.order, and ctf.core.tensor.shape.
Referenced by ctf.core.tensor.__setitem__().
| def ctf.core.tensor.prnt | ( | self | ) | 
| def ctf.core.tensor.ravel | ( | self, | |
| order = "F" | |||
| ) | 
| def ctf.core.tensor.read | ( | self, | |
| init_inds, | |||
| vals = None, | |||
| a = None, | |||
| b = None | |||
| ) | 
read(init_inds, vals=None, a=None, b=None) Helper function on reading a tensor.
Definition at line 1809 of file core.pyx.
References ctf.core.tensor.dt, ctf.core.tensor.dtype, ctf.core.tensor.ndim, and ctf.core.tensor.shape.
Referenced by ctf.core.tensor.__getitem__().
| def ctf.core.tensor.read_all | ( | self, | |
| arr = None, | |||
| unpack = True | |||
| ) | 
read_all(arr=None, unpack=True) Helper function on reading a tensor.
Definition at line 2088 of file core.pyx.
References ctf.core.tensor.dtype.
Referenced by ctf.core.tensor.to_nparray().
| def ctf.core.tensor.read_from_file | ( | self, | |
| path, | |||
| with_vals = True | |||
| ) | 
Definition at line 1272 of file core.pyx.
References ctf.core.tensor.dt, ctf.core.tensor.dtype, and ctf.core.tensor.sp.
| def ctf.core.tensor.read_local | ( | self | ) | 
read_local() Helper function on reading a tensor.
Definition at line 1966 of file core.pyx.
References ctf.core.tensor.dtype.
| def ctf.core.tensor.read_local_nnz | ( | self | ) | 
read_local_nnz() Helper function on reading a tensor.
Definition at line 2062 of file core.pyx.
References ctf.core.tensor.dtype.
Referenced by ctf.core.tensor.reshape().
| def ctf.core.tensor.real | ( | self, | |
| tensor, | |||
| value = None | |||
| ) | 
real(value = None)
Return real part of a tensor or set its real part to new value.
Returns
-------
value: tensor_like
    The value tensor set real to the original tensor, current only support value tensor with dtype `np.float64` or `np.complex128`. Default is none.
See Also
--------
ctf: ctf.reshape()
Examples
--------
>>> import ctf
>>> a = ctf.astensor([1+2j, 3+4j])
>>> b = ctf.astensor([5,6], dtype=np.float64)
>>> a.real(value = b)
>>> a
array([5.+2.j, 6.+4.j])
 
Definition at line 1595 of file core.pyx.
References ctf.core.tensor.__cinit__(), CTF_int::algstrct.copy(), CTF::Set< dtype, is_ord >.copy(), ctf.core.tensor.copy(), ctf.core.tensor.dt, ctf.core.tensor.dtype, and ctf.core.tensor.shape.
| def ctf.core.tensor.reshape | ( | self, | |
| integer | |||
| ) | 
reshape(*integer)
Return a new tensor with reshaped shape.
Returns
-------
output: tensor_like
    Output reshaped tensor.
See Also
--------
ctf: ctf.reshape()
Examples
--------
>>> import ctf
>>> a = ctf.astensor([[1,2,3],[4,5,6]])
>>> a.reshape(6,1)
array([[1],
       [2],
       [3],
       [4],
       [5],
       [6]])
 
Definition at line 1712 of file core.pyx.
References ctf.core.tensor.dtype, CTF_int::tensor.read_local_nnz(), ctf.core.tensor.read_local_nnz(), ctf.core.tensor.shape, and ctf.core.tensor.sp.
Referenced by ctf.core.tensor.__getitem__(), and ctf.core.tensor.all().
| def ctf.core.tensor.sample | ( | tensor, | |
| self, | |||
| p | |||
| ) | 
sample(p)
Extract a sample of the entries (if sparse of the current nonzeros) by keeping each entry with probability p. Also transforms tensor into sparse format if not already.
Parameters
----------
p: float
    Probability that keep each entry.
Returns
-------
output: tensor or scalar
    Elements extracted from the input tensor.
Examples
--------
>>> import ctf
>>> a = ctf.astensor([[1,2,3], [4,5,6], [7,8,9]])
>>> a.sample(0.1)
>>> a
array([[0, 0, 3],
       [0, 0, 6],
       [0, 0, 0]])
 
Definition at line 2761 of file core.pyx.
References ctf.core.tensor.dt, ctf.core.tensor.dtype, ctf.core.tensor.ndim, ctf.core.tensor.shape, ctf.core.tensor.sp, and CTF_int.subsample().
| def ctf.core.tensor.set_all | ( | self, | |
| value | |||
| ) | 
set_all(value)
Set all elements in a tensor to a value.
Parameters
----------
value: scalar
    Value set to a tensor.
Examples
--------
>>> import ctf
>>> a = ctf.astensor([1,2,3])
>>> a.set_all(3)
>>> a
array([3, 3, 3])
 
Definition at line 2394 of file core.pyx.
References ctf.core.tensor.dtype, and ctf.core.tensor.itemsize.
Referenced by ctf.core.tensor.__setitem__().
| def ctf.core.tensor.set_zero | ( | self | ) | 
Definition at line 2374 of file core.pyx.
References CTF_int::int1.i, CTF_int::int2.i, CTF::Tensor< dtype >.i(), ctf.core.tensor.i(), ctf.core.tensor.ndim, and ctf.core.scl().
Referenced by ctf.core.tensor.__idiv__(), ctf.core.tensor.__imul__(), ctf.core.tensor.__itruediv__(), ctf.core.tensor.__setitem__(), and ctf.core.tensor.set_zero().
| def ctf.core.tensor.set_zero | ( | self | ) | 
set_zero() Set all elements in a tensor to zero. Examples -------- >>> import ctf >>> a = ctf.astensor([1,2,3]) >>> a.set_zero() >>> a array([0, 0, 0])
Definition at line 2378 of file core.pyx.
References CTF_int::int1.i, CTF_int::int2.i, CTF::Tensor< dtype >.i(), ctf.core.tensor.i(), ctf.core.tensor.ndim, ctf.core.scl(), and ctf.core.tensor.set_zero().
| def ctf.core.tensor.sum | ( | self, | |
| axis = None, | |||
| dtype = None, | |||
| out = None, | |||
| keepdims = None | |||
| ) | 
sum(axis = None, dtype = None, out = None, keepdims = None)
Sum of elements in tensor or along specified axis.
Parameters
----------
axis: None, int or tuple of ints
    Axis or axes where the sum of elements is performed.
dtype: data-type, optional
    Data-type for the output tensor.
out: tensor, optional
    Alternative output tensor.
keepdims: None, bool, optional
    If set to true, axes summed over will remain size one.
Returns
-------
output: tensor_like
    Output tensor.
See Also
--------
numpy: numpy.sum()
Examples
--------
>>> import ctf
>>> a = ctf.ones([3,4], dtype=np.int64)
>>> a.sum()
12
 
| def ctf.core.tensor.T | ( | self | ) | 
tensor.T(axes=None)
Permute the dimensions of the input tensor.
Returns
-------
output: tensor
    Tensor with permuted axes.
See Also
--------
ctf: ctf.transpose
Examples
--------
>>> import ctf
>>> a = ctf.zeros([3,4,5])
>>> a.shape
(3, 4, 5)
>>> a.T().shape
(5, 4, 3)
 
Definition at line 876 of file core.pyx.
References ctf.core.tensor.transpose().
| def ctf.core.tensor.take | ( | self, | |
| indices, | |||
| axis = None, | |||
| out = None, | |||
| mode = 'raise' | |||
| ) | 
take(indices, axis=None, out=None, mode='raise')
Take elements from a tensor along axis.
Parameters
----------
indices: tensor_like
    Indices of the values wnat to be extracted.
axis: int, optional
    Select values from which axis, default None.
out: tensor
    Currently not supported in CTF Python take().
mode: {‘raise’, ‘wrap’, ‘clip’}, optional
    Currently not supported in CTF Python take().
Returns
-------
output: tensor or scalar
    Elements extracted from the input tensor.
See Also
--------
numpy: numpy.take()
Examples
--------
>>> import ctf
>>> a = ctf.astensor([[1,2,3], [4,5,6], [7,8,9]])
>>> a.take([0, 1, 2])
array([1, 2, 3])
 
| def ctf.core.tensor.tensordot | ( | self, | |
| other, | |||
| axes | |||
| ) | 
tensordot(other, axes=2)
Return the tensor dot product of two tensors along axes.
Parameters
----------
other: tensor_like
    Second input tensor.
axes: int or array_like
    Sum over which axes.
Returns
-------
output: tensor
    Tensor dot product of two tensors.
See Also
--------
numpy: numpy.tensordot()
Examples
--------
>>> import ctf
>>> import numpy as np
>>> a = np.arange(60.).reshape(3,4,5)
>>> b = np.arange(24.).reshape(4,3,2)
>>> a = ctf.astensor(a)
>>> b = ctf.astensor(b)
>>> a.tensordot(b, axes=([1,0],[0,1]))
array([[4400., 4730.],
       [4532., 4874.],
       [4664., 5018.],
       [4796., 5162.],
       [4928., 5306.]])
 
| def ctf.core.tensor.to_nparray | ( | self | ) | 
to_nparray()
Convert tensor to numpy ndarray.
Returns
-------
output: ndarray
    Numpy ndarray of the tensor.
Examples
--------
>>> import ctf
>>> a = ctf.ones([3,4], dtype=np.float64)
>>> a = ctf.ones([3,4])
>>> a.to_nparray()
array([[1., 1., 1., 1.],
       [1., 1., 1., 1.],
       [1., 1., 1., 1.]])
 
Definition at line 2652 of file core.pyx.
References ctf.core.tensor._tot_size(), ctf.core.tensor.dtype, CTF::Tensor< dtype >.read_all(), ctf.core.tensor.read_all(), and ctf.core.tensor.shape.
Referenced by ctf.core.tensor.__float__(), ctf.core.tensor.__int__(), ctf.core.tensor.__nonzero__(), and ctf.core.tensor.__repr__().
| def ctf.core.tensor.trace | ( | self, | |
| offset = 0, | |||
| axis1 = 0, | |||
| axis2 = 1, | |||
| dtype = None, | |||
| out = None | |||
| ) | 
trace(offset=0, axis1=0, axis2=1, dtype=None, out=None)
Return the sum over the diagonal of input tensor.
Parameters
----------
offset: int, optional
    Default is 0 which indicates the main diagonal.
axis1: int, optional
    Default is 0 which indicates the first axis of 2-D tensor where diagonal is taken.
axis2: int, optional
    Default is 1 which indicates the second axis of 2-D tensor where diagonal is taken.
dtype: data-type, optional
    Numpy data-type, currently not supported in CTF Python trace().
out: tensor
    Currently not supported in CTF Python trace().
Returns
-------
output: tensor or scalar
    Sum along diagonal of input tensor.
See Also
--------
ctf: ctf.trace()
Examples
--------
>>> import ctf
>>> a = ctf.astensor([[1,2,3], [4,5,6], [7,8,9]])
>>> a.trace()
15
 
| def ctf.core.tensor.transpose | ( | self, | |
| axes | |||
| ) | 
tensor.transpose(*axes)
Return the transposed tensor with specified order of axes.
Returns
-------
output: tensor
    Tensor with permuted axes.
See Also
--------
ctf: ctf.transpose
Examples
--------
>>> import ctf
>>> a = ctf.zeros([3,4,5])
>>> a.shape
(3, 4, 5)
>>> a.transpose([2,1,0]).shape
(5, 4, 3)
 
Definition at line 901 of file core.pyx.
References ctf.core.tensor.dtype, ctf.core.tensor.ndim, CTF::Partition.order, CTF_int::topology.order, CTF_int::strp_tsr.order, CTF_int::distribution.order, CTF_int::seq_tsr_scl.order, CTF_int::tensor.order, CTF_int::tspsum_permute.order, CTF_int::spctr_pin_keys.order, CTF_int::tspsum_pin_keys.order, ctf.core.tensor.order, ctf.core.tensor.shape, ctf.core.tensor.sp, CTF_int::seq_tsr_scl.sym, CTF_int::tensor.sym, and ctf.core.tensor.sym.
Referenced by ctf.core.tensor.T().
| def ctf.core.tensor.write | ( | self, | |
| init_inds, | |||
| init_vals, | |||
| a = None, | |||
| b = None | |||
| ) | 
write(init_inds, init_vals, a=None, b=None) Helper function on writing a tensor.
Definition at line 2210 of file core.pyx.
References ctf.core.tensor.dtype, ctf.core.tensor.ndim, and ctf.core.tensor.shape.
Referenced by ctf.core.tensor.__setitem__(), and ctf.core.tensor.from_nparray().
| def ctf.core.tensor.write_all | ( | self, | |
| arr | |||
| ) | 
write_all(arr) Helper function on writing a tensor.
Definition at line 2106 of file core.pyx.
References ctf.core.tensor.dtype.
Referenced by ctf.core.tensor.from_nparray().
| def ctf.core.tensor.write_to_file | ( | self, | |
| path, | |||
| with_vals = True | |||
| ) | 
Definition at line 1291 of file core.pyx.
References ctf.core.tensor.dt, ctf.core.tensor.dtype, and ctf.core.tensor.sp.
| ctf.core.tensor.dt | 
Definition at line 839 of file core.pyx.
Referenced by ctf.core.tensor.__dealloc__(), ctf.core.tensor.__get__(), ctf.core.tensor.__pow__(), ctf.core.tensor.all(), ctf.core.tensor.fill_random(), ctf.core.tensor.fill_sp_random(), ctf.core.tensor.imag(), ctf.core.tensor.norm1(), ctf.core.tensor.norm2(), ctf.core.tensor.norm_infty(), ctf.core.tensor.read(), ctf.core.tensor.read_from_file(), ctf.core.tensor.real(), ctf.core.tensor.sample(), and ctf.core.tensor.write_to_file().
| ctf.core.tensor.dtype | 
Definition at line 791 of file core.pyx.
Referenced by ctf.core.tensor.__get__(), ctf.core.tensor.__getitem__(), ctf.core.tensor.__iadd__(), ctf.core.tensor.__idiv__(), ctf.core.tensor.__imul__(), ctf.core.tensor.__isub__(), ctf.core.tensor.__itruediv__(), ctf.core.tensor.__neg__(), ctf.core.tensor.__pow__(), ctf.core.tensor.__richcmp__(), ctf.core.tensor.__setitem__(), ctf.core.tensor.all(), ctf.core.tensor.astype(), ctf.core.tensor.copy(), ctf.core.tensor.fill_random(), ctf.core.tensor.fill_sp_random(), ctf.core.tensor.from_nparray(), ctf.core.tensor.get_type(), ctf.core.tensor.imag(), ctf.core.tensor.norm1(), ctf.core.tensor.norm2(), ctf.core.tensor.norm_infty(), ctf.core.tensor.permute(), ctf.core.tensor.read(), ctf.core.tensor.read_all(), ctf.core.tensor.read_from_file(), ctf.core.tensor.read_local(), ctf.core.tensor.read_local_nnz(), ctf.core.tensor.real(), ctf.core.tensor.reshape(), ctf.core.tensor.sample(), ctf.core.tensor.set_all(), ctf.core.tensor.to_nparray(), ctf.core.tensor.transpose(), ctf.core.tensor.write(), ctf.core.tensor.write_all(), and ctf.core.tensor.write_to_file().
| ctf.core.tensor.itemsize | 
Definition at line 811 of file core.pyx.
Referenced by ctf.core.tensor.__get__(), ctf.core.tensor.astype(), and ctf.core.tensor.set_all().
| ctf.core.tensor.nbytes | 
Definition at line 817 of file core.pyx.
Referenced by ctf.core.tensor.__get__().
| ctf.core.tensor.ndim | 
Definition at line 800 of file core.pyx.
Referenced by ctf.core.tensor.__get__(), ctf.core.tensor.__getitem__(), ctf.core.tensor.__iadd__(), ctf.core.tensor.__idiv__(), ctf.core.tensor.__imul__(), ctf.core.tensor.__isub__(), ctf.core.tensor.__itruediv__(), ctf.core.tensor.__setitem__(), ctf.core.tensor.all(), ctf.core.tensor.permute(), ctf.core.tensor.read(), ctf.core.tensor.sample(), ctf.core.tensor.set_zero(), ctf.core.tensor.transpose(), and ctf.core.tensor.write().
| ctf.core.tensor.order | 
Definition at line 802 of file core.pyx.
Referenced by ctf.core.tensor.__get__(), ctf.core.tensor.__getitem__(), ctf.core.tensor.__setitem__(), ctf.core.tensor.i(), ctf.core.tensor.permute(), and ctf.core.tensor.transpose().
| ctf.core.tensor.shape | 
Definition at line 799 of file core.pyx.
Referenced by ctf.core.tensor.__deepcopy__(), ctf.core.tensor.__float__(), ctf.core.tensor.__get__(), ctf.core.tensor.__int__(), ctf.core.tensor.__nonzero__(), ctf.core.tensor.all(), ctf.core.tensor.astype(), ctf.core.tensor.copy(), ctf.core.tensor.get_dims(), ctf.core.tensor.imag(), ctf.core.tensor.permute(), ctf.core.tensor.read(), ctf.core.tensor.real(), ctf.core.tensor.reshape(), ctf.core.tensor.sample(), ctf.core.tensor.to_nparray(), ctf.core.tensor.transpose(), and ctf.core.tensor.write().
| ctf.core.tensor.size | 
Definition at line 814 of file core.pyx.
Referenced by ctf.core.tensor.__float__(), ctf.core.tensor.__get__(), ctf.core.tensor.__int__(), and ctf.core.tensor.__nonzero__().
| ctf.core.tensor.sp | 
Definition at line 805 of file core.pyx.
Referenced by ctf.core.tensor.__get__(), ctf.core.tensor.__getitem__(), ctf.core.tensor.read_from_file(), ctf.core.tensor.reshape(), ctf.core.tensor.sample(), ctf.core.tensor.transpose(), and ctf.core.tensor.write_to_file().
| ctf.core.tensor.strides | 
Definition at line 824 of file core.pyx.
Referenced by ctf.core.tensor.__get__().
| ctf.core.tensor.sym | 
Definition at line 807 of file core.pyx.
Referenced by ctf.core.tensor.__get__(), and ctf.core.tensor.transpose().