spLib
Loading...
Searching...
No Matches
spLVector Class Reference

Vector type that contains the elements of long type. More...

#include <sp/vector.h>

Collaboration diagram for spLVector:
Collaboration graph

Public Member Functions

Text I/O for Vector (<sp/fileio.h>)
spBool lvreadlvector_txt (const char *filename, spLVector vector)
 
spLVector xlvreadlvector_txt (const char *filename)
 
spBool lvreadcol_txt (const char *filename, int col, spLVector vector)
 
spLVector xlvreadcol_txt (const char *filename, int col)
 
spBool lvwritelvector_txt (const char *filename, spLVector vector)
 
Vector Dump (<sp/fileio.h>)
void lvdump (spLVector vec)
 
void lvfdump (spLVector vec, FILE *fp)
 
void lvnfdump (FILE *fp,...)
 
Memory Allocation and Deallocation
spLVector xlvalloc (long length)
 
void xlvfree (spLVector vector)
 
spLVector xlvallocul (spPlugin *plugin, long length, spBool unlock_flag)
 
spLVector xlvalloculfromv (spLVector x, long length)
 
void lvrfree (spLVector x)
 
void lvialloc (spLVector x)
 
void lvifree (spLVector x)
 
spLVector xlvriallocul (spPlugin *plugin, long length, spBool unlock_flag)
 
spLVector xlvrialloc (long length)
 
spLVector xlvrealloc (spLVector x, long length)
 
Lock and Unlock
spBool lvisplugincomputable (spLVector x)
 
spBool lvislocked (spLVector x)
 
spBool lvlock (spLVector x)
 
spBool lvunlock (spLVector x)
 
spBool lvsetlock (spLVector x, spBool lock)
 
spBool lvsync (spLVector x)
 
Complex Number Handling
spLVector xlvcplx (spLVector xr, spLVector xi)
 
void lvreal (spLVector x)
 
void lvimag (spLVector x)
 
spLVector xlvreal (spLVector x)
 
spLVector xlvimag (spLVector x)
 
void lvconj (spLVector x)
 
spLVector xlvconj (spLVector x)
 
void lvriswap (spLVector x)
 
spLVector xlvriswap (spLVector x)
 
Data Copy
void lvcopy (spLVector y, spLVector x)
 
void lvrcopyi (spLVector y, spLVector x)
 
void lvicopyr (spLVector y, spLVector x)
 
long lvcopyfromarray (spLVector y, long y_offset, long *data, long length)
 
long lvcopyfromriarray (spLVector y, long y_offset, long *data, long *imag, long length)
 
long lvcopytoarray (spLVector x, long x_offset, long *data, long length)
 
long lvcopytoriarray (spLVector x, long x_offset, long *data, long *imag, long length)
 
spLVector xlvclone (spLVector x)
 
spLVector xlvcat (spLVector x, spLVector y)
 
void lvcat (spLVector x, spLVector y)
 
Data Initialization
spBool lvinit (spLVector x, long m, long incr, long n)
 
spLVector xlvinit (long m, long incr, long n)
 
spLVector xlvinitul (spPlugin *plugin, long m, long incr, long n, spBool unlock_flag)
 
spBool lviinit (spLVector x, long m, long incr, long n)
 
spBool lvriinit (spLVector x, long m, long incr, long n)
 
spLVector xlvriinit (long m, long incr, long n)
 
spLVector xlvriinitul (spPlugin *plugin, long m, long incr, long n, spBool unlock_flag)
 
Data Editing
spLVector xlvcut (spLVector x, long offset, long length)
 
long lvpaste (spLVector y, spLVector x, long y_offset, long x_length, spBool overlap)
 
long lvadd (spLVector y, long y_offset, spLVector x, long x_offset, long x_length, spBool overlap)
 
void lverase (spLVector x, long offset, long length, spBool inv)
 
Data Modification
void lvset (spLVector x, long *data, long length)
 
void lviset (spLVector x, long *imag, long length)
 
spLVector xlvsetve (spPlugin *plugin, long *data, long length)
 
spLVector xlvset (long *data, long length)
 
spLVector xlvsetnew (long *data, long length)
 
spBool lvsetval (spLVector x, long index, long value)
 
spBool lvsetival (spLVector x, long index, long value)
 
Absolute Value (<sp/vmath.h>)
void lvabs (spLVector x)
 
spLVector xlvabs (spLVector x)
 
Square Root (<sp/vmath.h>)
void lvsqrt (spLVector x)
 
spLVector xlvsqrt (spLVector x)
 
Square (<sp/vmath.h>)
void lvsquare (spLVector x)
 
spLVector xlvsquare (spLVector x)
 
Sign Function (<sp/vmath.h>)
void lvsign (spLVector x)
 
spLVector xlvsign (spLVector x)
 
Cumulative Sum (<sp/vmath.h>)
void lvcumsum (spLVector x)
 
spLVector xlvcumsum (spLVector x)
 
Cumulative Product (<sp/vmath.h>)
void lvcumprod (spLVector x)
 
spLVector xlvcumprod (spLVector x)
 
Differences (<sp/vmath.h>)
void lvcodiff (spLVector x, double coef)
 
spLVector xlvcodiff (spLVector x, double coef)
 
#define lvdiff(x)   lvcodiff(x, 1.0);
 
#define xlvdiff(x)   xlvcodiff(x, 1.0);
 
Sum (<sp/vmath.h>)
long lvsum (spLVector x)
 
long lvisum (spLVector x)
 
long lvsqsum (spLVector x)
 
long lvabssum (spLVector x)
 
Product (<sp/vmath.h>)
long lvprod (spLVector x)
 
long lvriprod (spLVector x, long *oiprod)
 
Norm (<sp/vmath.h>)
double lvnorm (spLVector x, long p)
 
Dot Product (<sp/vmath.h>)
long lvdot (spLVector x, spLVector y)
 
void lvcplxdot (spLVector x, spLVector y, long *re, long *im)
 
Mean and Variance (<sp/vmath.h>)
double lvvar (spLVector x, double *mean)
 
double lvstd (spLVector x, double *mean)
 
#define lvmean(x)   ((double)lvsum(x) / (double)x->length)
 
Minimum and Maximum (<sp/vmath.h>)
long lvmin (spLVector x, long *index)
 
long lvmax (spLVector x, long *index)
 
void lvscmin (spLVector x, long a)
 
void lvscmax (spLVector x, long a)
 
void lvelmin (spLVector x, spLVector y)
 
void lvelmax (spLVector x, spLVector y)
 
Sort and Median (<sp/vmath.h>)
void lvsort (spLVector x)
 
spLVector xlvsort (spLVector x)
 
spLVector xlvsortidx (spLVector x)
 
double lvmedian (spLVector x)
 
spLVector xlvmedian (spLVector x, double *median)
 
Zero-Crossing Count (<sp/vmath.h>)
long lvzerocross (spLVector x, int slope_sign)
 
Vector Operation (<sp/voperate.h>)
void lvoper (spLVector a, const char *op, spLVector b)
 
spLVector xlvoper (spLVector a, const char *op, spLVector b)
 
void lvscoper (spLVector a, const char *op, double t)
 
spLVector xlvscoper (spLVector a, const char *op, double t)
 
void lvcplxoper (spLVector a, const char *op, double tr, double ti)
 
spLVector xlvcplxoper (spLVector a, const char *op, double tr, double ti)
 
Element Reorder (<sp/voperate.h>)
spLVector xlvremap (spLVector x, spLVector map)
 
Element Extraction (<sp/voperate.h>)
spLVector xlvfind (spLVector x)
 
spLVector xlvfindv (spLVector x)
 
Element Comparison (<sp/voperate.h>)
void lvsceval (spLVector x, const char *op, long t)
 
spLVector xlvsceval (spLVector x, const char *op, long t)
 
spLVector xlvscfind (spLVector x, const char *op, long t)
 
spLVector xlvscfindv (spLVector x, const char *op, long t)
 

Data Fields

long length
 
long * data
 
long * imag
 

Related Symbols

(Note that these are not member symbols.)

#define lvnums(x, length, value)   lvinit(x, (long)(value), 0, (long)(length))
 
#define lvzeros(x, length)   lvnums(x, length, 0)
 
#define lvones(x, length)   lvnums(x, length, 1)
 
#define lvinums(x, length, value)   lviinit(x, (long)(value), 0, (long)(length))
 
#define lvizeros(x, length)   lvinums(x, length, 0.0)
 
#define lviones(x, length)   lvinums(x, length, 1.0)
 
#define lvrinums(x, length, value)   lvriinit(x, (long)(value), 0, (long)(length))
 
#define lvrizeros(x, length)   lvrinums(x, length, 0.0)
 
#define lvriones(x, length)   lvrinums(x, length, 1.0)
 
#define xlvnums(length, value)   xlvinit((long)(value), 0, (long)(length))
 
#define xlvnumsul(plugin, length, value, unlock_flag)   xlvinitul(plugin, (long)(value), 0, (long)(length), unlock_flag)
 
#define xlvzeros(length)   xlvnums(length, 0)
 
#define xlvzerosul(plugin, length, unlock_flag)   xlvnumsul(plugin, length, 0, unlock_flag)
 
#define xlvones(length)   xlvnums(length, 1)
 
#define xlvonesul(plugin, length, unlock_flag)   xlvnumsul(plugin, length, 1, unlock_flag)
 
#define xlvnull()   xlvalloc(0)
 
#define xlvnullul(plugin, unlock_flag)   xlvallocul(plugin, 0, unlock_flag)
 
#define xlvrinums(length, value)   xlvriinit((long)(value), 0, (long)(length))
 
#define xlvrinumsul(plugin, length, value, unlock_flag)   xlvriinitul(plugin, (long)(value), 0, (long)(length), unlock_flag)
 
#define xlvrizeros(length)   xlvrinums(length, 0)
 
#define xlvrizerosul(plugin, length, unlock_flag)   xlvrinumsul(plugin, length, 0, unlock_flag)
 
#define xlvriones(length)   xlvrinums(length, 1)
 
#define xlvrionesul(plugin, length, unlock_flag)   xlvrinumsul(plugin, length, 1, unlock_flag)
 
#define lvunset(x)   lvset(x, NULL, 0)
 
#define lviunset(x)   lviset(x, NULL, 0)
 

File I/O for Vector (<sp/fileio.h>)

spLVector xlvreadlsignal (const char *filename, long headlen, int swap)
 
spBool lvwritelsignal (const char *filename, spLVector vector, int swap)
 
#define xlvreadlvector(filename, swap)   xlvreadlsignal((filename), 0, (swap))
 
#define lvwritelvector(filename, vector, swap)   lvwritelsignal(filename, vector, swap)
 

Detailed Description

Vector type that contains the elements of long type.

Actually, This is a typedefed type by typedef struct _spLVector *spLVector;. To allocate memory for spLVector, call a function with prefix xlv such as xlvalloc() , xlvinit() , etc. To deallocate memory, call xlvfree() .

Examples
mattest.c, and vectest.c.

Member Function Documentation

◆ xlvalloc()

spLVector xlvalloc ( long length)

Allocates memory for spLVector.

◆ xlvfree()

void xlvfree ( spLVector vector)

Deallocates memory for spLVector.

◆ xlvallocul()

spLVector xlvallocul ( spPlugin * plugin,
long length,
spBool unlock_flag )

Allocates memory for spLVector and sets it in the lock/unlock state.

◆ xlvalloculfromv()

spLVector xlvalloculfromv ( spLVector x,
long length )

Allocates memory for spLVector and updates its lock/unlock state by using the status of the input vector.

◆ lvrfree()

void lvrfree ( spLVector x)

Deallocates memory of the real part for spLVector.

◆ lvialloc()

void lvialloc ( spLVector x)

Allocates memory of the imaginary part for spLVector.

◆ lvifree()

void lvifree ( spLVector x)

Deallocates memory of the imaginary part for spLVector.

◆ xlvriallocul()

spLVector xlvriallocul ( spPlugin * plugin,
long length,
spBool unlock_flag )

Allocates memory of both the real and imaginary parts for spLVector and sets it in the lock/unlock state.

◆ xlvrialloc()

spLVector xlvrialloc ( long length)

Allocates memory of both the real and imaginary parts for spLVector.

◆ xlvrealloc()

spLVector xlvrealloc ( spLVector x,
long length )

Expands the size of the vector and resets the expanded elements to 0.

Returns
The address of x for success, SP_NODATA for failure.

◆ lvisplugincomputable()

spBool lvisplugincomputable ( spLVector x)

Checks whether the vector is ready for plugin-based computation.

◆ lvislocked()

spBool lvislocked ( spLVector x)

Checks whether the vector is in the locked state.

◆ lvlock()

spBool lvlock ( spLVector x)

Sets the vector in the locked state.

◆ lvunlock()

spBool lvunlock ( spLVector x)

Sets the vector in the unlocked state.

◆ lvsetlock()

spBool lvsetlock ( spLVector x,
spBool lock )

Sets the vector in the locked/unlocked state without data synchronization.

◆ lvsync()

spBool lvsync ( spLVector x)

Synchronizes the vector data (->data and ->imag) with the internal data without changing the locked/unlocked state.

◆ xlvcplx()

spLVector xlvcplx ( spLVector xr,
spLVector xi )

Creates a new vector whose real and imaginary parts are xr and xi , respectively.

◆ lvreal()

void lvreal ( spLVector x)

Deallocates the imaginary part of x if it exists.

◆ lvimag()

void lvimag ( spLVector x)

Sets the imaginary part of x as the real part.

◆ xlvreal()

spLVector xlvreal ( spLVector x)

Copies the real part of x to that of a new vector.

◆ xlvimag()

spLVector xlvimag ( spLVector x)

Copies the imaginary part of x to the real part of a new vector.

◆ lvconj()

void lvconj ( spLVector x)

Takes the complex conjugate of x.

◆ xlvconj()

spLVector xlvconj ( spLVector x)

Creates a new vector which is the complex conjugate of x.

◆ lvriswap()

void lvriswap ( spLVector x)

Swaps the real part of x for the imaginary part.

◆ xlvriswap()

spLVector xlvriswap ( spLVector x)

Creates a new vector whose real and imaginary parts are the imaginary and real parts of x respectively.

◆ lvcopy()

void lvcopy ( spLVector y,
spLVector x )

Copies data of x to y . The imaginary part of x is not copied unless y->imag != NULL.

◆ lvrcopyi()

void lvrcopyi ( spLVector y,
spLVector x )

Copies data of the real part of x to the imaginary part of y .

◆ lvicopyr()

void lvicopyr ( spLVector y,
spLVector x )

Copies data of the imaginary part of x to the real part of y .

◆ lvcopyfromarray()

long lvcopyfromarray ( spLVector y,
long y_offset,
long * data,
long length )

Copies data of the array data to the target location y_offset of y .

◆ lvcopyfromriarray()

long lvcopyfromriarray ( spLVector y,
long y_offset,
long * data,
long * imag,
long length )

Copies the complex array of the real part data and the imaginary part imag to the target location y_offset of y .

◆ lvcopytoarray()

long lvcopytoarray ( spLVector x,
long x_offset,
long * data,
long length )

Copies data extracted from x_offset of x to the array data .

◆ lvcopytoriarray()

long lvcopytoriarray ( spLVector x,
long x_offset,
long * data,
long * imag,
long length )

Copies data extracted from x_offset of x to the complex array of the real part data and the imaginary part imag .

◆ xlvclone()

spLVector xlvclone ( spLVector x)

Copies data of x to a new vector.

◆ xlvcat()

spLVector xlvcat ( spLVector x,
spLVector y )

Appends data of y to a new vector which is a clone of x.

◆ lvcat()

void lvcat ( spLVector x,
spLVector y )

Appends data of y to x.

◆ lvinit()

spBool lvinit ( spLVector x,
long m,
long incr,
long n )

Initialize the vector x so that the elements range from m to n using incr as the increment between elements.

◆ xlvinit()

spLVector xlvinit ( long m,
long incr,
long n )

Creates a new vector ranging from m to n using incr as the increment between elements.

◆ xlvinitul()

spLVector xlvinitul ( spPlugin * plugin,
long m,
long incr,
long n,
spBool unlock_flag )

Creates a new plugin-based vector ranging from m to n using incr as the increment between elements.

◆ lviinit()

spBool lviinit ( spLVector x,
long m,
long incr,
long n )

Initialize the imaginary part of the vector x so that the elements range from m to n using incr as the increment between elements.

◆ lvriinit()

spBool lvriinit ( spLVector x,
long m,
long incr,
long n )

Initialize the real and imaginary parts of the vector x so that the elements of both parts range from m to n using incr as the increment between elements.

◆ xlvriinit()

spLVector xlvriinit ( long m,
long incr,
long n )

Creates a new vector whose real and imaginary parts range from m to n using incr as the increment between elements.

◆ xlvriinitul()

spLVector xlvriinitul ( spPlugin * plugin,
long m,
long incr,
long n,
spBool unlock_flag )

Creates a new plugin-based vector whose real and imaginary parts range from m to n using incr as the increment between elements.

◆ xlvcut()

spLVector xlvcut ( spLVector x,
long offset,
long length )

Extracts data of length from offset of x .

◆ lvpaste()

long lvpaste ( spLVector y,
spLVector x,
long y_offset,
long x_length,
spBool overlap )

Pastes data of x cropped with x_length to the target location y_offset of y . The argument overlap determines whether the overlap addition is performed in pasting data.

◆ lvadd()

long lvadd ( spLVector y,
long y_offset,
spLVector x,
long x_offset,
long x_length,
spBool overlap )

Pastes data of x_length extracted from x_offset of x to the target location y_offset of y . The argument overlap determines whether the overlap addition is performed in pasting data.

◆ lverase()

void lverase ( spLVector x,
long offset,
long length,
spBool inv )

Erases data of length from offset . The argument inv determines whether the erasing location is inverted.

◆ lvset()

void lvset ( spLVector x,
long * data,
long length )

Sets the address of data to x->data .

◆ lviset()

void lviset ( spLVector x,
long * imag,
long length )

Sets the address of imag to x->imag .

◆ xlvsetve()

spLVector xlvsetve ( spPlugin * plugin,
long * data,
long length )

Sets the address of data to data of a plugin-based new vector.

◆ xlvset()

spLVector xlvset ( long * data,
long length )

Sets the address of data to data of a new vector.

◆ xlvsetnew()

spLVector xlvsetnew ( long * data,
long length )

Creates a new vector whose real part is a clone of data .

◆ lvsetval()

spBool lvsetval ( spLVector x,
long index,
long value )

Copies a value to the location of index of the real part of x .

◆ lvsetival()

spBool lvsetival ( spLVector x,
long index,
long value )

Copies a value to the location of index of the imaginary part of x .

Friends And Related Symbol Documentation

◆ lvnums

#define lvnums ( x,
length,
value )   lvinit(x, (long)(value), 0, (long)(length))
related

Initialize the vector x so that the elements within length are all value .

◆ lvzeros

#define lvzeros ( x,
length )   lvnums(x, length, 0)
related

Initialize the vector x so that the elements within length are all zeros.

◆ lvones

#define lvones ( x,
length )   lvnums(x, length, 1)
related

Initialize the vector x so that the elements within length are all ones.

◆ lvinums

#define lvinums ( x,
length,
value )   lviinit(x, (long)(value), 0, (long)(length))
related

Initialize the imaginary part of the vector x so that the elements within length are all value .

◆ lvizeros

#define lvizeros ( x,
length )   lvinums(x, length, 0.0)
related

Initialize the imaginary part of the vector x so that the elements within length are all zeros.

◆ lviones

#define lviones ( x,
length )   lvinums(x, length, 1.0)
related

Initialize the imaginary part of the vector x so that the elements within length are all ones.

◆ lvrinums

#define lvrinums ( x,
length,
value )   lvriinit(x, (long)(value), 0, (long)(length))
related

Initialize the real and imaginary parts of the vector x so that the elements of both parts are all value .

◆ lvrizeros

#define lvrizeros ( x,
length )   lvrinums(x, length, 0.0)
related

Initialize the real and imaginary parts of the vector x so that the elements of both parts are all zeros.

◆ lvriones

#define lvriones ( x,
length )   lvrinums(x, length, 1.0)
related

Initialize the real and imaginary parts of the vector x so that the elements of both parts are all ones.

◆ xlvnums

#define xlvnums ( length,
value )   xlvinit((long)(value), 0, (long)(length))
related

Creates a new vector whose elements within length are all value .

◆ xlvnumsul

#define xlvnumsul ( plugin,
length,
value,
unlock_flag )   xlvinitul(plugin, (long)(value), 0, (long)(length), unlock_flag)
related

Creates a new plugin-based vector whose elements within length are all value .

◆ xlvzeros

#define xlvzeros ( length)    xlvnums(length, 0)
related

Creates a new vector whose elements within length are all zeros.

◆ xlvzerosul

#define xlvzerosul ( plugin,
length,
unlock_flag )   xlvnumsul(plugin, length, 0, unlock_flag)
related

Creates a new plugin-based vector whose elements within length are all zeros.

◆ xlvones

#define xlvones ( length)    xlvnums(length, 1)
related

Creates a new vector whose elements within length are all ones.

◆ xlvonesul

#define xlvonesul ( plugin,
length,
unlock_flag )   xlvnumsul(plugin, length, 1, unlock_flag)
related

Creates a new plugin-based vector whose elements within length are all ones.

◆ xlvnull

#define xlvnull ( )    xlvalloc(0)
related

Creates a new null vector.

◆ xlvnullul

#define xlvnullul ( plugin,
unlock_flag )   xlvallocul(plugin, 0, unlock_flag)
related

Creates a new null plugin-based vector.

◆ xlvrinums

#define xlvrinums ( length,
value )   xlvriinit((long)(value), 0, (long)(length))
related

Creates a new vector whose real and imaginary parts are all value .

◆ xlvrinumsul

#define xlvrinumsul ( plugin,
length,
value,
unlock_flag )   xlvriinitul(plugin, (long)(value), 0, (long)(length), unlock_flag)
related

Creates a new plugin-based vector whose real and imaginary parts are all value .

◆ xlvrizeros

#define xlvrizeros ( length)    xlvrinums(length, 0)
related

Creates a new vector whose real and imaginary parts are all zeros.

◆ xlvrizerosul

#define xlvrizerosul ( plugin,
length,
unlock_flag )   xlvrinumsul(plugin, length, 0, unlock_flag)
related

Creates a new plugin-based vector whose real and imaginary parts are all zeros.

◆ xlvriones

#define xlvriones ( length)    xlvrinums(length, 1)
related

Creates a new vector whose real and imaginary parts are all ones.

◆ xlvrionesul

#define xlvrionesul ( plugin,
length,
unlock_flag )   xlvrinumsul(plugin, length, 1, unlock_flag)
related

Creates a new plugin-based vector whose real and imaginary parts are all ones.

◆ lvunset

#define lvunset ( x)    lvset(x, NULL, 0)
related

Sets x->data to NULL.

◆ lviunset

#define lviunset ( x)    lviset(x, NULL, 0)
related

Sets x->imag to NULL.

Field Documentation

◆ length

long length

The number of elements of spLVector. You can access the number of elements as x->length for the memory allocated x of spLVector.

◆ data

long* data

Data of the real part of spLVector. You can access the 0-th element of the data as x->data[0] for the memory allocated x of spLVector.

◆ imag

long* imag

Data of the imaginary part of spLVector. You can access the 0-th element of the data as x->imag[0] for the memory allocated x of spLVector. If no imaginary part exists, this member can be NULL.