33.4 Complex double vectors

Module: sage.modules.complex_double_vector

Complex double vectors

The SAGE ComplexDoubleVector class supports optimized computation with vectors whose entries are complex double precision numbers. The underlying arithmetic is implemented by the GSL library.

sage: v = vector(CDF,[(1,-1), (2,pi), (3,5)])
sage: v
(1.0 - 1.0*I, 2.0 + 3.14159265359*I, 3.0 + 5.0*I)
sage: type(v)
<type 'sage.modules.complex_double_vector.ComplexDoubleVectorSpaceElement'>
sage: parent(v)
Vector space of dimension 3 over Complex Double Field
sage: v[0] = 5  
sage: v
(5.0, 2.0 + 3.14159265359*I, 3.0 + 5.0*I)
sage: loads(dumps(v)) == v
True

Author Log:

Module-level Functions

unpickle_v0( )

unpickle_v1( )

Class: ComplexDoubleVectorSpaceElement

class ComplexDoubleVectorSpaceElement

Functions: fft,$ \,$ inv_fft,$ \,$ n,$ \,$ numpy

fft( )

This performs a fast fourier transform on the vector.

Input:

direction
- 'forward' (default) or 'backward'
inplace
- bool (default: False), use True to do an in-place Fourier transform

This function is fastest if the vector's length is a power of 2.

sage: v = vector(CDF,[1,2,3,4])
sage: w = v.fft()
sage: v2 = w.fft(direction='backward')

inv_fft( )

This performs the inverse fast fourier transform on the vector.

The fourier transform can be done in place using the keyword inplace=True

This will be fastest if the vector's length is a power of 2.

sage: v = vector(CDF,[1,2,3,4])
sage: w = v.fft()
sage: v - w.inv_fft()    # random -- should be very close to 0.
(0, 0, 0, 0)

n( )

Returns a numerical approximation of self by calling the n() method on all of its entries.

sage: v = vector(CDF, [1,2,3])
sage: v.n()
(1.00000000000000, 2.00000000000000, 3.00000000000000)
sage: _.parent()
Vector space of dimension 3 over Real Field with 53 bits of precision
sage: v.n(prec=75)
(1.000000000000000000000, 2.000000000000000000000, 3.000000000000000000000)
sage: _.parent()
Vector space of dimension 3 over Real Field with 75 bits of precision

numpy( )

Return numpy array corresponding to this vector.

sage: v = vector(CDF,4,range(4))
sage: v.numpy()
array([ 0.+0.j,  1.+0.j,  2.+0.j,  3.+0.j])
sage: v = vector(CDF,0)
sage: v.numpy()
array([], dtype=complex128)

Special Functions: __copy__,$ \,$ __delitem__,$ \,$ __getitem__,$ \,$ __init__,$ \,$ __len__,$ \,$ __reduce__,$ \,$ __setitem__,$ \,$ _replace_self_with_numpy

__copy__( )

__getitem__( )

Return the ith entry of self.

sage: v = vector(CDF, [1,CDF(3,2), -1]); v
(1.0, 3.0 + 2.0*I, -1.0)
sage: v[1]
3.0 + 2.0*I
sage: v[-1]
-1.0
sage: v[5]
Traceback (most recent call last):
...
IndexError: index out of range

__reduce__( )

_replace_self_with_numpy( )

See About this document... for information on suggesting changes.