Hi Waldek, here is the code
monact.spad for MonoidAction pgn.spad with the code of the two domains I already sent in the orginal note finite.spad where the required OneToN is defined To run the examples yourself, you in addition need a modified perm.spad, which I could send including input files for the problems, if necessary. Am 04.11.15 um 15:12 schrieb Waldek Hebisch: > Prof. Dr. Johannes Grabmeier wrote: >> I desperately look for the reason of a strange behaviour of compiled >> SPAD code: >> >> I have coded a category MonoidAction with default code containing the >> code for "orbit" using the group action * > I do not see code for MonoidAction in your post. Without it its is > impossible to debug this. And just looking at code tells me > nothing (OK, there is error durinig initialization, but what > gets initialized, when and why depend on whole code). > -- Mit freundlichen Grüßen Johannes Grabmeier Fraktionsvorsitzender FREIE WÄHLER, Stadtrat Deggendorf Prof. Dr. Johannes Grabmeier Köckstraße 1, D-94469 Deggendorf Tel. +49-(0)-991-2979584, Tel. +49-(0)-151-681-70756 Fax: +49-(0)-3224-192688 -- You received this message because you are subscribed to the Google Groups "FriCAS - computer algebra system" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/fricas-devel. For more options, visit https://groups.google.com/d/optout.
bingyWNKQQXnO.bin
Description: application/applefile
finite.spad
Description: Binary data
)abbrev category MONACT MonoidAction
++ Author: Johannes Grabmeier
++ Date Created: 2015-10-30
++ Date Last Updated: 2015-10-31
++ Basic Functions: * a monoid operates on a set.
++ to be implemented: action
++ all the other function have default implementation
++ Related Constructors: MonoidRing
++ Also See:
++ AMS Classifications:
++ Keywords:
++ References:
++ Description:
++ \spadtype{MonoidAction} is the category for monoid or group actions on a set.
--MonoidAction(G: Monoid): Category == Join(SetCategory, InternalMessageLevel)
with
MonoidAction(G: Monoid): Category == SetCategory with
--operations
"*": (G, %) -> %
++ g*x is the result of the action of g in G on an element x.
action: (G, %) -> %
++ action(g, x) is the result of the action of g in G on an element x.
actionElement: (%,%) -> Union(G, "failed")
++ actionElement(v, w) finds a g in G such that gv = w, "failed" if w
not in orbit of v.
orbit: % -> List %
++ orbit(v) constructs the orbit of v in % under the group action.
orbitLength: % -> NonNegativeInteger
++ orbitLength(v) yields length of orbit of v.
stabilizer: % -> List G
++ stabilizer(v) yields list of elements g in G s.th. gv = v
orbit: List % -> List %
++ orbit(lv) constructs the union of all orbits of v' in lv.
orbitLengths: List % -> List NonNegativeInteger
++ orbitLengths(lv) yields length of orbits of v in lv.
add
import OutputForm
-- -- hash(s : %): SingleInteger == 0$SingleInteger
action(g: G, v: %): % == g*v
if G has Finite then
enG : List G := enumerate()$G
orbit(v: %): List % ==
--print blankSeparate [message "enG = ", enG::OutputForm]
removeDuplicates [g*v for g in enG]
orbitLength(v: %): NonNegativeInteger == # orbit v
stabilizer(v: %): List G ==
lig : List G := []
for g in enG repeat if g*v=v then lig := cons(g,lig)
lig
-- does compile, but does not work:
--[g | g*v=v for g in enG]
orbit(lv: List %): List % ==
o : List % := []
for v in lv repeat o := concat(o, orbit v)
removeDuplicates o
orbitLengths(lv: List %): List NonNegativeInteger == [orbitLength v for v
in lv]
actionElement(v: %, w: %): Union(G, "failed") ==
found : Boolean := false
h : G := 1
for g in enG while not found repeat
found := (g*v = w)
--print blankSeparate [message "actionElement g = ",
g::OutputForm]
--print blankSeparate [message "actionElement found = ",
found::OutputForm]
if found then h := g
if found then h else "failed"
)abbrev domain PGM PermutationGroupOnN
PermutationGroupOnN(n: PositiveInteger): Exports == Implementation where
G ==> Permutation OneToN(n)
Exports ==> Join(MonoidAction(G), SetCategory, Finite, StepThrough,
OrderedFinite, RetractableFrom Integer, RetractableTo Integer,
RetractableTo PositiveInteger)
Implementation ==> OneToN(n) add
Rep := OneToN(n)
((g: G) * (v: %)): % == eval(g,v::Rep)$G
)abbrev domain CYC2DV CyclicTwoDimensionalVelocity
CyclicTwoDimensionalVelocity(R: Field, d: Symbol): Exports == Implementation
where
G ==> CyclicGroup(4, d)
Exports ==> MonoidAction(G) with
construct: (R, R) -> %
++ [vx,vy] constructs a 2 dim velocity element.
first : % -> R
second : % -> R
Implementation ==> List R add
Rep := List R
D : G := first generators()$G
construct(vx: R, vy: R): % == [vx,vy]
first(v: %): R == v.1
second(v: %): R == v.2
((g: G) * (v: %)): % ==
g = D => [- second v, first v]
g = D*D => [- first v,- second v]
g = D*D*D => [second v,- first v]
v
