RTableCopyImPart - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

# Online Help

###### All Products    Maple    MapleSim

RTableIsReal

test if an rtable contains only real data in external code

RTableCopyImPart

create a copy of only the imaginary part of a complex rtable in external code

RTableCopyRealPart

create a copy of only the real part of a complex rtable in external code

RTableZipReIm

combine two rtables into a single complex rtable in external code

 Calling Sequence RTableIsReal(kv, rt) RTableCopyImPart(kv, rts, rt) RTableCopyRealPart(kv, rts, rt) RTableZipReIm(kv, rts, rt_re, rt_im)

Parameters

 kv - kernel handle of type MKernelVector rt, rt_re, rt_im - type ALGEB rtable objects rts - pointer to an RTableSettings structure

Description

 • These functions can be used in external code with OpenMaple or define_external.
 • RTableIsReal tests if a rtable contains only real-valued numeric data.  A scan of the data is only done for rtables with data_type = RTABLE_DAG.  When the data_type is RTABLE_COMPLEX or RTABLE_CXDAG, FALSE is immediately returned.  For all other data_types, TRUE is immediately returned.
 • RTableCopyRealPart creates a new rtable containing only the real part of complex numeric data in the rtable rt.  The new rtable has the settings in the supplied OpenMaple/C/RTableSettings structure.
 • RTableCopyImPart creates a new rtable containing only the imaginary part of complex numeric data in the rtable rt.  The result is an ordinary rtable of numeric data.  If the specified data_type of rt is RTABLE_CXDAG or RTABLE_COMPLEX, the new rtable has 0s in the imaginary part, and the copied data in the real part. The new rtable has the settings in the supplied OpenMaple/C/RTableSettings structure.
 • RTableZipReIm combines two real numeric rtables rt_re and rt_im into a complex rtable of the form rt_re + I*rt_im. Both rtables must be the same size.  The new rtable has the settings in the supplied OpenMaple/C/RTableSettings structure, provided such settings allow for storage of complex data.

Examples

 #include "maplec.h" ALGEB M_DECL MyFilterIm( MKernelVector kv, ALGEB *args ) { M_INT argc, i, numelems; RTableSettings rts; ALGEB rt, zero, rel, im, r, evalb; FLOAT64 val; ComplexFloat64 *fdata; ALGEB *adata; CXDAG *cdata; argc = MapleNumArgs(kv,(ALGEB)args); if( argc != 2 ) { MapleRaiseError(kv,"two arguments expected"); return( NULL ); } rt = args[1]; if( !IsMapleRTable(kv,rt) ) { MapleRaiseError(kv,"rtable expected"); return( NULL ); } if( RTableIsReal(kv,rt) ) return( rt ); RTableGetSettings(kv,&rts,rt); if( MapleNumArgs(kv,rts.index_functions) != 0 ) { MapleRaiseError(kv,"cannot handle rtable with indexing function"); return( NULL ); } if( rts.read_only ) { MapleRaiseError(kv,"cannot modify read-only rtable"); return( NULL ); } numelems = RTableNumElements(kv,rt); switch( rts.data_type ) { case RTABLE_DAG: adata = (ALGEB*)RTableDataBlock(kv,rt); evalb = ToMapleName(kv,"evalb",TRUE); for( i=0; i",args[2],im); if( (r=EvalMapleProc(kv,evalb,1,rel)) && MapleToInteger8(kv,r) ) { adata[i] = MapleSelectRealPart(kv,adata[i]); } } break; case RTABLE_CXDAG: cdata = (CXDAG*)RTableDataBlock(kv,rt); evalb = ToMapleName(kv,"evalb",TRUE); zero = ToMapleFloat(kv,0.0); for( i=0; i",args[2],cdata[i].im); if( (r=EvalMapleProc(kv,evalb,1,rel)) && MapleToInteger8(kv,r) ) { cdata[i].im = zero; } } RTableSetType(kv,&rts,RTABLE_DAG,"anything"); break; case RTABLE_COMPLEX: fdata = (ComplexFloat64*)RTableDataBlock(kv,rt); val = MapleToFloat64(kv,args[2]); for( i=0; i

Execute the external function from Maple.

 > $\mathrm{with}\left(\mathrm{ExternalCalling}\right):$
 > $\mathrm{dll}≔\mathrm{ExternalLibraryName}\left("HelpExamples"\right):$
 > $\mathrm{filterIm}≔\mathrm{DefineExternal}\left("MyFilterIm",\mathrm{dll}\right):$
 > $V≔{\mathrm{Vector}}_{\mathrm{row}}\left(8,i→i+iI\right)$
 ${V}{≔}\left[\begin{array}{cccccccc}{1}{+}{I}& {2}{+}{2}{}{I}& {3}{+}{3}{}{I}& {4}{+}{4}{}{I}& {5}{+}{5}{}{I}& {6}{+}{6}{}{I}& {7}{+}{7}{}{I}& {8}{+}{8}{}{I}\end{array}\right]$ (1)
 > $\mathrm{filterIm}\left(V,4\right)$
 $\left[\begin{array}{cccccccc}{0}& {0}& {0}& {4}& {5}& {6}& {7}& {8}\end{array}\right]$ (2)
 > $V$
 $\left[\begin{array}{cccccccc}{1}& {2}& {3}& {4}{+}{4}{}{I}& {5}{+}{5}{}{I}& {6}{+}{6}{}{I}& {7}{+}{7}{}{I}& {8}{+}{8}{}{I}\end{array}\right]$ (3)
 > $V≔\mathrm{Vector}\left(5,i→\frac{1}{i}+\frac{1I}{i},\mathrm{datatype}=\mathrm{complex}\left(\mathrm{sfloat}\right)\right)$
 ${V}{≔}\left[\begin{array}{c}{1.}{+}{I}\\ {0.5000000000}{+}{0.5000000000}{}{I}\\ {0.3333333333}{+}{0.3333333333}{}{I}\\ {0.2500000000}{+}{0.2500000000}{}{I}\\ {0.2000000000}{+}{0.2000000000}{}{I}\end{array}\right]$ (4)
 > $\mathrm{filterIm}\left(V,0.5\right)$
 $\left[\begin{array}{c}{1.}\\ {0.5000000000}\\ {0.}\\ {0.}\\ {0.}\end{array}\right]$ (5)
 > $V≔\mathrm{Vector}\left(5,i→i+\left(\frac{1}{i}-0.4\right)I,\mathrm{datatype}=\mathrm{complex}\left({\mathrm{float}}_{8}\right)\right)$
 ${V}{≔}\left[\begin{array}{c}{1.}{+}{0.600000000000000}{}{I}\\ {2.}{+}{0.100000000000000}{}{I}\\ {3.}{-}{0.0666666667000000}{}{I}\\ {4.}{-}{0.150000000000000}{}{I}\\ {5.}{-}{0.200000000000000}{}{I}\end{array}\right]$ (6)
 > $\mathrm{filterIm}\left(V,0\right)$
 $\left[\begin{array}{c}{0.600000000000000}\\ {0.100000000000000}\\ {0.}\\ {0.}\\ {0.}\end{array}\right]$ (7)

 See Also