Items tagged with record record Tagged Items Feed

Hi everyone,

I would like to use structs

    struct sname {
        smem1;
        smem2;
    }

in my C code defined elsewhere. How do I get CodeGeneration to produce variable names like

    sname.smem1

?

The appoach to use the respective maple data type

  sname := Record('smem1', 'smem2'):
  CodeGeneration[C](sname);

results in

    Warning, procedure/module options ignored
    double smem1;
    double smem2;

and the appoach to define it as name

    CodeGeneration[C](`sname.smem1`);

results in

    Warning, the following variable name replacements were made: sname.smem1 -> cg0
    cg = cg0;

Your answer is appreciated

Fabian

Hi,

Following situation: I have Records with several members. These members in turn have varied expressions assigned to them: some have numbers, one has a Matrix, some have formulae. Example:

q:=Record(l=len,k1=kl/len,R=(a 6x6 Matrix dependent on len and kl/len));

I want to be able to use the limit command on each of the members of q such that each member gets assigned the correct limit of its expression. I.e. I want to write a function limit2 such that

limit2(q,len=0);

yields

Record(l=0,k1=infinity,R=(limit~(the Matrix,len=0))

The trick here is that the members of the Record vary for different Records but I want to write a function limit2 that works for all of these. I can make a list of the members by using exports(q) like this:

exlist:=[exports(q)];

and after some fiddling I found that I can run limit on each member in turn:

for nam in exlist do
  limit~(eval(parse(cat(elm,":-",eval(nam)))),len=0)
end do;

What I have not been able to do is putting the result back into the member of the Record. Usually I would use assign for such a task, but I am unable to get the correct name on the left side that lets me assign to it. These names would of course be q:-l, q:-k1 and q:-R in the above example. I tried the parse(cat(...)) construct above and variations, but in the best case the assignment does not happen, in worse cases I get an error thrown. Never do I get the actual assignment.

Any hint how to do this?

TIA,

M.D.

PS: FWIW, I am doing this on Mape 15.

 

I am trying to define a new typt and I am beating my head against the wall...

What I have working:

TypeTools:-AddType(Element,'record(l,R)');
 
This defines a type which I can then use in type(xpr,Element) to be false or true depending on whether xpr is a record containing (at least) entries l and R or not.

Now I want to define a type ExpandedLine that is a Vector of Element (Element in the sense above). In fact, in the context of my application I am willing to settle for ExpandedLine being a Vector of record.

Tried various approaches (and making sure Vector is in uneval quotes in the AddType statement) like:

TypeTools:-AddType(ExpandedLine,'Vector'(record));

and variations but no luck.

Any help is appreciated.

Mac Dude

 

Find a loop do define these matrices, even for large values of n. Record the Matrix Mn 

 

all i,j=1,2,13,..,n for example 

N := `<|>`(`<,>`(1, 2), `<,>`(2, 2))

P := `<|>`(`<,>`(1, 2, 3), `<,>`(2, 2, 3), `<,>`(3, 3, 3))

Q := `<|>`(`<,>`(1, 2, 3, 4), `<,>`(2, 2, 3, 4), `<,>`(3, 3, 3, 4), `<,>`(4, 4, 4, 4))

 

Please help!!!

I have a procedure which accepts arguments of a (created by myself) type which are records, like so:

Subs:=proc(eqn::seq(equation),elemt::Element,$);
...

Here "Element" is  type I have defined; it is a record with certain fields present.

My question: will this work with option remember? I have the procedure sort-of working without the remember option, but I need to make it work recursively (the Element record can have fields which contain names of other records of type Element...

Hi; I am working on a package where the data mostly come in Maple records with a varisble number of fields with different names. At least one field in each record has a 6 by 6 matrix, the expressions of which involve the values associated with at least some of the other fields.

Occasionally I have the need to, say, apply a function to each of these fields. E.g., I want to substitute a value for a specific name; this name may show up in several fields and also will show up in the matrix.

In matlab, a function is returned a structure H, say H.a, H.b, ...

In maple, I want to call this matlab function, but what returned to maple is a Record:

 

Hs:= getvar("H");

Hs:= Record(a=..., b=..., ...);

 

So how can I convert this record to a normal maple array? so I can access to each element by Hs[1]. 

 

Thank you

Kyle

Here are 30 all-time men's best 100m  (see http://en.wikipedia.org/wiki/100_metres
 and  http://www.alltime-athletics.com/m_100ok.htm )
        1      9.58       +0.9    Usain Bolt          16.08.2009

Page 1 of 1