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

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

#include <sp/vector.h>

Collaboration diagram for spSVector:
Collaboration graph

Public Member Functions

Text I/O for Vector (<sp/fileio.h>)
spBool svreadsvector_txt (const char *filename, spSVector vector)
 
spSVector xsvreadsvector_txt (const char *filename)
 
spBool svreadcol_txt (const char *filename, int col, spSVector vector)
 
spSVector xsvreadcol_txt (const char *filename, int col)
 
spBool svwritesvector_txt (const char *filename, spSVector vector)
 
Vector Dump (<sp/fileio.h>)
void svdump (spSVector vec)
 
void svfdump (spSVector vec, FILE *fp)
 
void svnfdump (FILE *fp,...)
 
Memory Allocation and Deallocation
spSVector xsvalloc (long length)
 
void xsvfree (spSVector vector)
 
spSVector xsvallocul (spPlugin *plugin, long length, spBool unlock_flag)
 
spSVector xsvalloculfromv (spSVector x, long length)
 
void svrfree (spSVector x)
 
void svialloc (spSVector x)
 
void svifree (spSVector x)
 
spSVector xsvriallocul (spPlugin *plugin, long length, spBool unlock_flag)
 
spSVector xsvrialloc (long length)
 
spSVector xsvrealloc (spSVector x, long length)
 
Lock and Unlock
spBool svisplugincomputable (spSVector x)
 
spBool svislocked (spSVector x)
 
spBool svlock (spSVector x)
 
spBool svunlock (spSVector x)
 
spBool svsetlock (spSVector x, spBool lock)
 
spBool svsync (spSVector x)
 
Complex Number Handling
spSVector xsvcplx (spSVector xr, spSVector xi)
 
void svreal (spSVector x)
 
void svimag (spSVector x)
 
spSVector xsvreal (spSVector x)
 
spSVector xsvimag (spSVector x)
 
void svconj (spSVector x)
 
spSVector xsvconj (spSVector x)
 
void svriswap (spSVector x)
 
spSVector xsvriswap (spSVector x)
 
Data Copy
void svcopy (spSVector y, spSVector x)
 
void svrcopyi (spSVector y, spSVector x)
 
void svicopyr (spSVector y, spSVector x)
 
long svcopyfromarray (spSVector y, long y_offset, short *data, long length)
 
long svcopyfromriarray (spSVector y, long y_offset, short *data, short *imag, long length)
 
long svcopytoarray (spSVector x, long x_offset, short *data, long length)
 
long svcopytoriarray (spSVector x, long x_offset, short *data, short *imag, long length)
 
spLVector xsvtol (spSVector x)
 
spFVector xsvtof (spSVector x)
 
spDVector xsvtod (spSVector x)
 
spSVector xsvclone (spSVector x)
 
spSVector xsvcat (spSVector x, spSVector y)
 
void svcat (spSVector x, spSVector y)
 
Data Initialization
spBool svinit (spSVector x, long m, long incr, long n)
 
spSVector xsvinit (long m, long incr, long n)
 
spSVector xsvinitul (spPlugin *plugin, long m, long incr, long n, spBool unlock_flag)
 
spBool sviinit (spSVector x, long m, long incr, long n)
 
spBool svriinit (spSVector x, long m, long incr, long n)
 
spSVector xsvriinit (long m, long incr, long n)
 
spSVector xsvriinitul (spPlugin *plugin, long m, long incr, long n, spBool unlock_flag)
 
Data Editing
spSVector xsvcut (spSVector x, long offset, long length)
 
long svpaste (spSVector y, spSVector x, long y_offset, long x_length, spBool overlap)
 
long svadd (spSVector y, long y_offset, spSVector x, long x_offset, long x_length, spBool overlap)
 
void sverase (spSVector x, long offset, long length, spBool inv)
 
Data Modification
void svset (spSVector x, short *data, long length)
 
void sviset (spSVector x, short *imag, long length)
 
spSVector xsvsetve (spPlugin *plugin, short *data, long length)
 
spSVector xsvset (short *data, long length)
 
spSVector xsvsetnew (short *data, long length)
 
spBool svsetval (spSVector x, long index, short value)
 
spBool svsetival (spSVector x, long index, short value)
 
Absolute Value (<sp/vmath.h>)
void svabs (spSVector x)
 
spSVector xsvabs (spSVector x)
 
Square Root (<sp/vmath.h>)
void svsqrt (spSVector x)
 
spSVector xsvsqrt (spSVector x)
 
Square (<sp/vmath.h>)
void svsquare (spSVector x)
 
spSVector xsvsquare (spSVector x)
 
Sign Function (<sp/vmath.h>)
void svsign (spSVector x)
 
spSVector xsvsign (spSVector x)
 
Cumulative Sum (<sp/vmath.h>)
void svcumsum (spSVector x)
 
spSVector xsvcumsum (spSVector x)
 
Cumulative Product (<sp/vmath.h>)
void svcumprod (spSVector x)
 
spSVector xsvcumprod (spSVector x)
 
Differences (<sp/vmath.h>)
void svcodiff (spSVector x, double coef)
 
spSVector xsvcodiff (spSVector x, double coef)
 
#define svdiff(x)   svcodiff(x, 1.0);
 
#define xsvdiff(x)   xsvcodiff(x, 1.0);
 
Sum (<sp/vmath.h>)
long svsum (spSVector x)
 
long svisum (spSVector x)
 
long svsqsum (spSVector x)
 
long svabssum (spSVector x)
 
Product (<sp/vmath.h>)
long svprod (spSVector x)
 
long svriprod (spSVector x, long *oiprod)
 
Norm (<sp/vmath.h>)
double svnorm (spSVector x, long p)
 
Dot Product (<sp/vmath.h>)
long svdot (spSVector x, spSVector y)
 
void svcplxdot (spSVector x, spSVector y, long *re, long *im)
 
Mean and Variance (<sp/vmath.h>)
double svvar (spSVector x, double *mean)
 
double svstd (spSVector x, double *mean)
 
#define svmean(x)   ((double)svsum(x) / (double)x->length)
 
Minimum and Maximum (<sp/vmath.h>)
short svmin (spSVector x, long *index)
 
short svmax (spSVector x, long *index)
 
void svscmin (spSVector x, short a)
 
void svscmax (spSVector x, short a)
 
void svelmin (spSVector x, spSVector y)
 
void svelmax (spSVector x, spSVector y)
 
Sort and Median (<sp/vmath.h>)
void svsort (spSVector x)
 
spSVector xsvsort (spSVector x)
 
spLVector xsvsortidx (spSVector x)
 
double svmedian (spSVector x)
 
spSVector xsvmedian (spSVector x, double *median)
 
Zero-Crossing Count (<sp/vmath.h>)
long svzerocross (spSVector x, int slope_sign)
 
Vector Operation (<sp/voperate.h>)
void svoper (spSVector a, const char *op, spSVector b)
 
spSVector xsvoper (spSVector a, const char *op, spSVector b)
 
void svscoper (spSVector a, const char *op, double t)
 
spSVector xsvscoper (spSVector a, const char *op, double t)
 
void svcplxoper (spSVector a, const char *op, double tr, double ti)
 
spSVector xsvcplxoper (spSVector a, const char *op, double tr, double ti)
 
Element Reorder (<sp/voperate.h>)
spSVector xsvremap (spSVector x, spLVector map)
 
Element Extraction (<sp/voperate.h>)
spLVector xsvfind (spSVector x)
 
spSVector xsvfindv (spSVector x)
 
Element Comparison (<sp/voperate.h>)
void svsceval (spSVector x, const char *op, short t)
 
spSVector xsvsceval (spSVector x, const char *op, short t)
 
spLVector xsvscfind (spSVector x, const char *op, short t)
 
spSVector xsvscfindv (spSVector x, const char *op, short t)
 

Data Fields

long length
 
short * data
 
short * imag
 

Related Symbols

(Note that these are not member symbols.)

#define svnums(x, length, value)   svinit(x, (long)(value), 0, (long)(length))
 
#define svzeros(x, length)   svnums(x, length, 0)
 
#define svones(x, length)   svnums(x, length, 1)
 
#define svinums(x, length, value)   sviinit(x, (long)(value), 0, (long)(length))
 
#define svizeros(x, length)   svinums(x, length, 0.0)
 
#define sviones(x, length)   svinums(x, length, 1.0)
 
#define svrinums(x, length, value)   svriinit(x, (long)(value), 0, (long)(length))
 
#define svrizeros(x, length)   svrinums(x, length, 0.0)
 
#define svriones(x, length)   svrinums(x, length, 1.0)
 
#define xsvnums(length, value)   xsvinit((long)(value), 0, (long)(length))
 
#define xsvnumsul(plugin, length, value, unlock_flag)   xsvinitul(plugin, (long)(value), 0, (long)(length), unlock_flag)
 
#define xsvzeros(length)   xsvnums(length, 0)
 
#define xsvzerosul(plugin, length, unlock_flag)   xsvnumsul(plugin, length, 0, unlock_flag)
 
#define xsvones(length)   xsvnums(length, 1)
 
#define xsvonesul(plugin, length, unlock_flag)   xsvnumsul(plugin, length, 1, unlock_flag)
 
#define xsvnull()   xsvalloc(0)
 
#define xsvnullul(plugin, unlock_flag)   xsvallocul(plugin, 0, unlock_flag)
 
#define xsvrinums(length, value)   xsvriinit((long)(value), 0, (long)(length))
 
#define xsvrinumsul(plugin, length, value, unlock_flag)   xsvriinitul(plugin, (long)(value), 0, (long)(length), unlock_flag)
 
#define xsvrizeros(length)   xsvrinums(length, 0)
 
#define xsvrizerosul(plugin, length, unlock_flag)   xsvrinumsul(plugin, length, 0, unlock_flag)
 
#define xsvriones(length)   xsvrinums(length, 1)
 
#define xsvrionesul(plugin, length, unlock_flag)   xsvrinumsul(plugin, length, 1, unlock_flag)
 
#define svunset(x)   svset(x, NULL, 0)
 
#define sviunset(x)   sviset(x, NULL, 0)
 

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

spSVector xsvreadssignal (const char *filename, long headlen, int swap)
 
spBool svwritessignal (const char *filename, spSVector vector, int swap)
 
#define xsvreadsvector(filename, swap)   xsvreadssignal((filename), 0, (swap))
 
#define svwritesvector(filename, vector, swap)   svwritessignal(filename, vector, swap)
 

Detailed Description

Vector type that contains the elements of short type.

Actually, This is a typedefed type by typedef struct _spSVector *spSVector;. To allocate memory for spSVector, call a function with prefix xsv such as xsvalloc() , xsvinit() , etc. To deallocate memory, call xsvfree() .

Examples
vectest.c.

Member Function Documentation

◆ xsvalloc()

spSVector xsvalloc ( long length)

Allocates memory for spSVector.

◆ xsvfree()

void xsvfree ( spSVector vector)

Deallocates memory for spSVector.

◆ xsvallocul()

spSVector xsvallocul ( spPlugin * plugin,
long length,
spBool unlock_flag )

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

◆ xsvalloculfromv()

spSVector xsvalloculfromv ( spSVector x,
long length )

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

◆ svrfree()

void svrfree ( spSVector x)

Deallocates memory of the real part for spSVector.

◆ svialloc()

void svialloc ( spSVector x)

Allocates memory of the imaginary part for spSVector.

◆ svifree()

void svifree ( spSVector x)

Deallocates memory of the imaginary part for spSVector.

◆ xsvriallocul()

spSVector xsvriallocul ( spPlugin * plugin,
long length,
spBool unlock_flag )

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

◆ xsvrialloc()

spSVector xsvrialloc ( long length)

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

◆ xsvrealloc()

spSVector xsvrealloc ( spSVector 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.

◆ svisplugincomputable()

spBool svisplugincomputable ( spSVector x)

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

◆ svislocked()

spBool svislocked ( spSVector x)

Checks whether the vector is in the locked state.

◆ svlock()

spBool svlock ( spSVector x)

Sets the vector in the locked state.

◆ svunlock()

spBool svunlock ( spSVector x)

Sets the vector in the unlocked state.

◆ svsetlock()

spBool svsetlock ( spSVector x,
spBool lock )

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

◆ svsync()

spBool svsync ( spSVector x)

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

◆ xsvcplx()

spSVector xsvcplx ( spSVector xr,
spSVector xi )

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

◆ svreal()

void svreal ( spSVector x)

Deallocates the imaginary part of x if it exists.

◆ svimag()

void svimag ( spSVector x)

Sets the imaginary part of x as the real part.

◆ xsvreal()

spSVector xsvreal ( spSVector x)

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

◆ xsvimag()

spSVector xsvimag ( spSVector x)

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

◆ svconj()

void svconj ( spSVector x)

Takes the complex conjugate of x.

◆ xsvconj()

spSVector xsvconj ( spSVector x)

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

◆ svriswap()

void svriswap ( spSVector x)

Swaps the real part of x for the imaginary part.

◆ xsvriswap()

spSVector xsvriswap ( spSVector x)

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

◆ svcopy()

void svcopy ( spSVector y,
spSVector x )

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

◆ svrcopyi()

void svrcopyi ( spSVector y,
spSVector x )

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

◆ svicopyr()

void svicopyr ( spSVector y,
spSVector x )

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

◆ svcopyfromarray()

long svcopyfromarray ( spSVector y,
long y_offset,
short * data,
long length )

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

◆ svcopyfromriarray()

long svcopyfromriarray ( spSVector y,
long y_offset,
short * data,
short * 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 .

◆ svcopytoarray()

long svcopytoarray ( spSVector x,
long x_offset,
short * data,
long length )

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

◆ svcopytoriarray()

long svcopytoriarray ( spSVector x,
long x_offset,
short * data,
short * 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 .

◆ xsvtol()

spLVector xsvtol ( spSVector x)

Copies data of x to a new vector with a different type.

◆ xsvtof()

spFVector xsvtof ( spSVector x)

Copies data of x to a new vector with a different type.

◆ xsvtod()

spDVector xsvtod ( spSVector x)

Copies data of x to a new vector with a different type.

◆ xsvclone()

spSVector xsvclone ( spSVector x)

Copies data of x to a new vector.

◆ xsvcat()

spSVector xsvcat ( spSVector x,
spSVector y )

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

◆ svcat()

void svcat ( spSVector x,
spSVector y )

Appends data of y to x.

◆ svinit()

spBool svinit ( spSVector 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.

◆ xsvinit()

spSVector xsvinit ( long m,
long incr,
long n )

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

◆ xsvinitul()

spSVector xsvinitul ( 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.

◆ sviinit()

spBool sviinit ( spSVector 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.

◆ svriinit()

spBool svriinit ( spSVector 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.

◆ xsvriinit()

spSVector xsvriinit ( 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.

◆ xsvriinitul()

spSVector xsvriinitul ( 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.

◆ xsvcut()

spSVector xsvcut ( spSVector x,
long offset,
long length )

Extracts data of length from offset of x .

◆ svpaste()

long svpaste ( spSVector y,
spSVector 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.

◆ svadd()

long svadd ( spSVector y,
long y_offset,
spSVector 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.

◆ sverase()

void sverase ( spSVector x,
long offset,
long length,
spBool inv )

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

◆ svset()

void svset ( spSVector x,
short * data,
long length )

Sets the address of data to x->data .

◆ sviset()

void sviset ( spSVector x,
short * imag,
long length )

Sets the address of imag to x->imag .

◆ xsvsetve()

spSVector xsvsetve ( spPlugin * plugin,
short * data,
long length )

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

◆ xsvset()

spSVector xsvset ( short * data,
long length )

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

◆ xsvsetnew()

spSVector xsvsetnew ( short * data,
long length )

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

◆ svsetval()

spBool svsetval ( spSVector x,
long index,
short value )

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

◆ svsetival()

spBool svsetival ( spSVector x,
long index,
short value )

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

Friends And Related Symbol Documentation

◆ svnums

#define svnums ( x,
length,
value )   svinit(x, (long)(value), 0, (long)(length))
related

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

◆ svzeros

#define svzeros ( x,
length )   svnums(x, length, 0)
related

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

◆ svones

#define svones ( x,
length )   svnums(x, length, 1)
related

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

◆ svinums

#define svinums ( x,
length,
value )   sviinit(x, (long)(value), 0, (long)(length))
related

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

◆ svizeros

#define svizeros ( x,
length )   svinums(x, length, 0.0)
related

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

◆ sviones

#define sviones ( x,
length )   svinums(x, length, 1.0)
related

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

◆ svrinums

#define svrinums ( x,
length,
value )   svriinit(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 .

◆ svrizeros

#define svrizeros ( x,
length )   svrinums(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.

◆ svriones

#define svriones ( x,
length )   svrinums(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.

◆ xsvnums

#define xsvnums ( length,
value )   xsvinit((long)(value), 0, (long)(length))
related

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

◆ xsvnumsul

#define xsvnumsul ( plugin,
length,
value,
unlock_flag )   xsvinitul(plugin, (long)(value), 0, (long)(length), unlock_flag)
related

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

◆ xsvzeros

#define xsvzeros ( length)    xsvnums(length, 0)
related

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

◆ xsvzerosul

#define xsvzerosul ( plugin,
length,
unlock_flag )   xsvnumsul(plugin, length, 0, unlock_flag)
related

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

◆ xsvones

#define xsvones ( length)    xsvnums(length, 1)
related

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

◆ xsvonesul

#define xsvonesul ( plugin,
length,
unlock_flag )   xsvnumsul(plugin, length, 1, unlock_flag)
related

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

◆ xsvnull

#define xsvnull ( )    xsvalloc(0)
related

Creates a new null vector.

◆ xsvnullul

#define xsvnullul ( plugin,
unlock_flag )   xsvallocul(plugin, 0, unlock_flag)
related

Creates a new null plugin-based vector.

◆ xsvrinums

#define xsvrinums ( length,
value )   xsvriinit((long)(value), 0, (long)(length))
related

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

◆ xsvrinumsul

#define xsvrinumsul ( plugin,
length,
value,
unlock_flag )   xsvriinitul(plugin, (long)(value), 0, (long)(length), unlock_flag)
related

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

◆ xsvrizeros

#define xsvrizeros ( length)    xsvrinums(length, 0)
related

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

◆ xsvrizerosul

#define xsvrizerosul ( plugin,
length,
unlock_flag )   xsvrinumsul(plugin, length, 0, unlock_flag)
related

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

◆ xsvriones

#define xsvriones ( length)    xsvrinums(length, 1)
related

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

◆ xsvrionesul

#define xsvrionesul ( plugin,
length,
unlock_flag )   xsvrinumsul(plugin, length, 1, unlock_flag)
related

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

◆ svunset

#define svunset ( x)    svset(x, NULL, 0)
related

Sets x->data to NULL.

◆ sviunset

#define sviunset ( x)    sviset(x, NULL, 0)
related

Sets x->imag to NULL.

Field Documentation

◆ length

long length

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

◆ data

short* data

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

◆ imag

short* imag

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