Art Kalb

237 Reputation

12 Badges

16 years, 313 days

MaplePrimes Activity


These are questions asked by Art Kalb

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?

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?

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.

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.

with(CodeGeneration)

testproc1 := proc (x) abs(x) end proc

IntermediateCode(testproc1, optimize = tryhard)

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)
    )
  ))
)

 

testproc2 := proc (x::numeric) abs(x) end proc

IntermediateCode(testproc2, optimize = tryhard)

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)
    )
  ))
)

 

NULL

testproc3 := proc (x::complex) abs(x) end proc

IntermediateCode(testproc3, optimize = tryhard)

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)
    )
  ))
)

 

NULL

Download intermediate_code_abs.mw

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.
 

alp := [a, b, c, d, e]

[a, b, c, d, e]

(1)

u[a] := Vector(5, proc (m) options operator, arrow; u[alp[m], a] end proc)

u[b] := Vector(5, proc (m) options operator, arrow; u[alp[m], b] end proc)

u[c] := Vector(5, proc (m) options operator, arrow; u[alp[m], c] end proc)

u[d] := Vector(5, proc (m) options operator, arrow; u[alp[m], d] end proc)

u[e] := Vector(5, proc (m) options operator, arrow; u[alp[m], e] end proc)

NULL

NULL

NULL

N := r[a]*u[a]+r[b]*u[b]+r[c]*u[c]+r[d]*u[d]+r[e]*u[e]

Vector[column](%id = 36893490335086041316)

(2)

``

LinearAlgebra:-HermitianTranspose(N)

Vector[row](%id = 36893490335105454316)

(3)

NULL


 

Download DistributeHermitian.mw

1 2 3 4 5 6 7 Page 1 of 8