## 237 Reputation

16 years, 310 days

## Saving a slice of an array to a reposito...

Maple

Trying to figure out how to save a slice of an array to a repository.

for example: savelib(vmcofs[1],lib) [where lib is my repository location]

I'm getting the error: Error, invalid input: savelib expects its 1st argument, to be of type symbol, but received vmcofs[1]

Quoting it doesn't seem to help.

I need to do this programmatically as I will be incremented the row number in the array and saving partial data at each step.

That is...savelib(vmcofs[1],lib) then savelib(vmcofs[2],lib), etc.

I can save the whole array. Is there a more efficient way of doing this?

## Any idea how to implement a group ring?...

Maple

I'm interested in created a group ring, but have no idea how to do it.

In short, a group ring is a free module with the scalars as elements of a ring,R, and the vectors as elements in a group, G. [Wikipedia has a decent description.]

Elements a=r0*g0 and b=r1*g1 have sum a+b=r0*g0+r1*g1 and product a*b=r0*r1*g0*g1

The distributive property is followed.

Suggestions?

## Replacing specific symbol with exponent ...

Maple

I'm stuck on trying to convert something like xi^p to H(p)*xi^p. p is an integer.

The variable I am using is xi and I want to just insert an H(p) term based on the order of xi (p). I want to do it for any occurence of xi. I don't want to convert other variables/symbols.

It would seem applyrule should work, except it goes into an endless loop.

I've tried other combinations but just don't seem to be able to figure out the right one.

It seems to me that I could try some sort of subsindet where the transformer checks the variable name, but that seems inefficient.

I'm going to guess there is a simple solution!

Thanks.

## How do you prevent Code Generation:-Inte...

Maple

I have been writing a language translator. I have everything working reasonably well except that when translating abs(expr) with optimize=tryhard, the IntermediateCode converts the abs() into if...then...else statements. This would be fine except the type of the expr is generally a complex number. I need to optimize the code because there is a lot of redundant calculations otherwise.

I can't figure out how to get IntermediateCode from breaking the abs function into if...then...else statements. [My solution so far is to substitute abs with a dummy name and then use the translator to translate the dummy name into an abs statement - That's really not how things should work!]

Any suggestions?

I've included some example test cases of what is going wrong.

 Scope( nametab,   AssignedName(Name("testproc1"), Scope( nametab,     Procedure(       ParameterSequence(Declaration(Name("x"), Type(integer))),       LocalSequence(Declaration(Name("s1"), Type(integer))),       OptionSequence(),       ExpressionSequence(),       StatementSequence(         If(           ConditionalPair(LessEqual(Integer(0), Name("x")), StatementSequence(             Assignment(Name("s1"), Name("x"))           )),           ConditionalPair(Less(Name("x"), Integer(0)), StatementSequence(             Assignment(Name("s1"), Negation(Name("x")))           )),           StatementSequence(             Assignment(Name("s1"), Integer(0))           )         ),         Return(Name("s1"))       ),       DescriptionSequence(),       GlobalSequence(),       LexicalSequence(),       Type(integer)     )   )) )

 Scope( nametab,   AssignedName(Name("testproc2"), Scope( nametab,     Procedure(       ParameterSequence(Declaration(Name("x"), Type(numeric))),       LocalSequence(Declaration(Name("s1"), Type(numeric))),       OptionSequence(),       ExpressionSequence(),       StatementSequence(         If(           ConditionalPair(LessEqual(Float(0, 0), Name("x")), StatementSequence(             Assignment(Name("s1"), Name("x"))           )),           ConditionalPair(Less(Name("x"), Float(0, 0)), StatementSequence(             Assignment(Name("s1"), Negation(Name("x")))           )),           StatementSequence(             Assignment(Name("s1"), Float(0, 0))           )         ),         Return(Name("s1"))       ),       DescriptionSequence(),       GlobalSequence(),       LexicalSequence(),       Type(numeric)     )   )) )

 Scope( nametab,   AssignedName(Name("testproc3"), Scope( nametab,     Procedure(       ParameterSequence(Declaration(Name("x"), Type(complex))),       LocalSequence(),       OptionSequence(),       ExpressionSequence(),       StatementSequence(         Return(FunctionCall(Name("abs"), ExpressionSequence(Name("x")), unknown))       ),       DescriptionSequence(),       GlobalSequence(),       LexicalSequence(),       Type(numeric)     )   )) )

## Distribute Hermitian Transpose...

Maple

Hi,

I'm trying to figure out how to get the HermitianTranpose vector to distribute over a sum of vectors. Maple seems to want to ignore the linearity of the conjugate operation.

See the example code attached.

Thanks.

 (1)

 (2)

 (3)