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
Parameters
Description
Examples
RTableIsReal(kv, rt)
RTableCopyImPart(kv, rts, rt)
RTableCopyRealPart(kv, rts, rt)
RTableZipReIm(kv, rts, rt_re, rt_im)
kv
-
kernel handle of type MKernelVector
rt, rt_re, rt_im
type ALGEB rtable objects
rts
pointer to an RTableSettings structure
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.
#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");
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");
if( rts.read_only ) {
MapleRaiseError(kv,"cannot modify read-only rtable");
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<numelems; ++i ) {
im = MapleSelectImaginaryPart(kv,adata[i]);
rel = ToMapleRelation(kv,">",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);
zero = ToMapleFloat(kv,0.0);
rel = ToMapleRelation(kv,">",args[2],cdata[i].im);
cdata[i].im = zero;
RTableSetType(kv,&rts,RTABLE_DAG,"anything");
case RTABLE_COMPLEX:
fdata = (ComplexFloat64*)RTableDataBlock(kv,rt);
val = MapleToFloat64(kv,args[2]);
if( fdata[i].im < val ) {
fdata[i].im = 0.0;
rts.data_type = RTABLE_FLOAT64;
return( RTableCopyImPart(kv,&rts,rt) );
Execute the external function from Maple.
with⁡ExternalCalling:
dll≔ExternalLibraryName⁡HelpExamples:
filterIm≔DefineExternal⁡MyFilterIm,dll:
V≔Vectorrow⁡8,i↦i+I⋅i
V≔1+I2+2⁢I3+3⁢I4+4⁢I5+5⁢I6+6⁢I7+7⁢I8+8⁢I
filterIm⁡V,4
00045678
V
1234+4⁢I5+5⁢I6+6⁢I7+7⁢I8+8⁢I
V≔Vector⁡5,i↦1i+Ii,datatype=complex⁡sfloat
V≔1.+I0.5000000000+0.5000000000⁢I0.3333333333+0.3333333333⁢I0.2500000000+0.2500000000⁢I0.2000000000+0.2000000000⁢I
filterIm⁡V,0.5
1.0.50000000000.0.0.
V≔Vector⁡5,i↦i+I⋅1i−0.4,datatype=complex⁡float8
V≔1.+0.600000000000000⁢I2.+0.100000000000000⁢I3.−0.0666666667000000⁢I4.−0.150000000000000⁢I5.−0.200000000000000⁢I
filterIm⁡V,0
0.6000000000000000.1000000000000000.0.0.
See Also
CustomWrapper
define_external
LinearAlgebra[Zip]
OpenMaple
OpenMaple/C/API
OpenMaple/C/Examples
rtable
Download Help Document