Items tagged with module module Tagged Items Feed

There are no examples for ModuleDeconstruct either on its help page or in the Programming Guide. Of course, I can figure out its basic and primarily intended purpose: to render the module/object in a one-dimensional plaintext printed form, which would be useful for debugging. But I am most interested in this use described in the second sentence of this, the second paragraph of Description at ?ModuleDeconstruct [italics added]:

When the value returned by ModuleDeconstruct is printed, the output could be capable of being parsed to the original module. When used with an object, ModuleDeconstruct can return an unevaluated call to a constructor to achieve this.

That seems very powerful. Is there any example of it being used in Maple library code? in user code? Can anyone here come up with a practical use for this? A Google search turns up nothing.

I ran into a problem mentioned here before: With lots of code in one execution group, the standard GUI editor becomes very slow at least in older versions of Maple (I have reason to believe that this is mostly fixed in Maple 17 and, presumably, newer). With one of my packages this has become enough of a problem to force me to deal with it (and Modules and Packages have to be all in one execution group). I have some machines that cannot go beyond Maple 15 so I keep my stuff compatible with it (so far not a big sacrifice).

The fix is rather easy: In the GUI, export the code as "Maple Input" which creates a file with extension .mpl. Then, in the GUI have a small file that uses "read" to read-in and execute the code (of the module). In my case, I have the necessary LibTools statement to save as a .mla right after the package code ends so, bingo, I have just updated the package. I edit the .mpl file in Emacs.

So I installed Joe Riel's Emacs mode maplev-mode.el. This works rather well. However, it took not long for it to show its age: it does not recognize the multi-line comments (*...*). This is kind-of bad as this forces me to not use quotes in the comments since they mess-up the keyword highlighting esp. when using single quotes as in "I'll" and so on. Likewise, maplev-indent-buffer messes up the whole buffer as it interprets the multiline comments as code.

So my question is: is someone still working on this and using it?? I guess I can work around some of these things, but it would be nice if this worked.

Incidentally, my version of maplev-mode.el seems to be dated June 2005.

I know Joe is here on occasion, maybe he can chime in. It is not absolutely fatal; I could forgo using maplev, but if I am forced to go this route of readin in the package; using maplev-mode at least gives me something in return. Unfortunately my elisp skills are not quite up to fixing this myself; at least not in a reasonable time.

If it is relevant: I use Emacs 22.1 on Mac OS X. Yes, I could upgrade to at least Emace 23.4, if that were the issue.

Thanks in advance,

Mac Dude

Hi,

I want to write a proc to calculate exponential averages. Each call will add one data point to the averge. To do that, I need to store the previous average. I can do that by handing the previous average back to the proc at the next call, but I'd rather store it in the proc. Is there a way to guarantee that a variable---once set---remains alive keeping the last value upon entering the proc again? Note that I need the variable to be local to each instance of the proc since I will have several of these running in parallel (I intend to create these procs using the module factory scheme outlined in the programming guide). So I cannot store the previous average in a global variable since that would not be unique to a given instance.

Any ideas out there?

TIA,

Mac Dude

 

Has anyone made use of the GeM module?  found here http://math.usask.ca/~shevyakov/gem/

 

 

Hello all of you,

I'm new here and I have a problem.

For homework I have to write a Maple package for the usage of dual quaternions. This is not a problem.

For example two functions of the package:

MyQuaternions := module()

  export Pretty, Ugly:
  local l1:
  option package:
 
  protect('i,j,k,epsilon'):
 
Pretty := proc(q::Vector)
  description "":
  return LinearAlgebra[Transpose](q)[1..4].Vector([1,i,j,k])+epsilon*(LinearAlgebra[Transpose](q)[5..8].Vector([1,i,j,k])):
end proc:

Ugly := proc(q)
  description "":
  local a;
  a := Vector(8);
  a[1]:=remove(has,remove(has,q,epsilon),{i,j,k});
  a[2]:=coeff(remove(has,q,epsilon),i,1);
  a[3]:=coeff(remove(has,q,epsilon),j,1);
  a[4]:=coeff(remove(has,q,epsilon),k,1);
  a[5]:=remove(has,coeff(q,epsilon),{i,j,k});
  a[6]:=coeff(coeff(q,epsilon),i,1);
  a[7]:=coeff(coeff(q,epsilon),j,1);
  a[8]:=coeff(coeff(q,epsilon),k,1);
  return a:
end proc:

end module:

savelib('MyQuaternions'):

 

Now I can load the module in a differnet maple worksheet "main.mw" by typing "with(MyQuaternions):"

The crucial thing now is the following: i,j,k,epsilon should be protected in "main.mw". I can do this by typing "protect('i,j,k,epsilon'):" Is there a way to tell maple to protect these variables automatically when the module is loaded? Or do I always have to type in the protect command by hand?

Thank you,

Josef

how to convert between (system of polynomials or module) and rational function which is a four dimensional space

1. is module in algebraic geometry or group cohomology to classify homology group?

2. is final result like this? for example,

a dictionary  or table store

homology group 1, key=invariant = 1 hole in topological space , value = module 1, module 2 module 3 etc

homology group 2, key=invariant = 2 holes in topological space , value =module 4, module 5, module 6 etc

homology group 3, key=invariant = 3 holes in topological space , value = module 7, module 8.. etc

 ... etc

 

3. i find betti number can count holes, however how to know the form for

all combination?

i mean if it is module, how to change the module to get the full combination

http://www.singular.uni-kl.de/Manual/html/sing_159.htm

i find betti number's input is just ideal, but it is not module

if ideal is enough, why need module?

how to permuate module? and what do it classify and result in module?

1. is module in algebraic geometry for classification of topological space which a poset is a frame

2. which invariant is for doing this classification of topological space in algebraic geometry or group cohomology?

3. if want to do full combination before classification, which kind of polynomials be a full combination

4. is poset just like function fst and snd function for meet and join in functional programming instead of using "and" and "or" logic? how a matrix group related with topological space which a poset is a frame?

5. is there any invariant function for classification of topological space in maple?

Hi all,

I have a problem when creating package by using 'read' function to concatenate package's elements

Case1: Create package normally, Proc1 and Proc2 are exported

restart;
###################################
# Define package Test contains 2 proc: Proc1 and Proc2
##################################
Test := module()
    option package;
    export Proc1, Proc2;

    Proc1 := proc()
        description "Proc1() is an element of package Test";
        printf("In Proc1\n");
    end proc;
    Proc2 := proc()
        description "Proc2 is an element of package Test";
        printf("In Proc2\n");
        Proc1();
    end proc;
end module;

#################################
# Try to call Proc1 from Proc2
#################################
Test:-Proc2();

Console output:

> Test:-Proc2();
In Proc2
In Proc1

==> The result looks OK

 

Case2: Split Proc1 into another file and include it into master file by using 'read' function, Proc1 and Proc2 are exported

restart;
###################################
# Define package Test contains 2 proc: Proc1 and Proc2
##################################
Test:= module()
    option package;
    export Proc1, Proc2;

    ###########################
    # Code to concatenate "Proc1.maple" here
    ###########################

    read "Test/Proc1.maple";

    Proc2 := proc()
        description "Proc2 is an element of package Test1";
        printf("In Proc2\n");
        Proc1();
    end proc;


end module;


#################################
# Try to call Proc1 from Proc2
#################################
Test:-Proc2();

Console output:

> Test:-Proc2();
In Proc2
                                    Proc1()

==> The Proc1 seem does not execute or evaluate

 

Case3: Split Proc1 into another file and include it into master file by using 'read' function, just export Proc2, not export Proc1

restart;

###################################
# Define package Test contains 2 proc: Proc1 and Proc2
##################################
Test:= module()
    option package;
    export Proc2;

    ###########################
    # Code to concatenate "Proc1.maple" here
    ###########################

    read "Test/Proc1.maple";

    Proc2 := proc()
        description "Proc2 is an element of package Test1";
        printf("In Proc2\n");
        Proc1();
    end proc;


end module;


#################################
# Try to call Proc1 from Proc2
#################################
Test:-Proc1();

Console output:

> Test:-Proc2();
In Proc2

In Proc1

==> The result looks good

 

Please help to explain the problem from case 2 and case 3. If I want to split package proc into many files, how can I do?

 

I've been using a maple package (written by another author) on earlier versions of Maple.  Recently I have been trying to rewrite it so it's a bit more Maple 16+ friendly (since I've read that Maple is not forward-compatible). However, I have been experiencing similar strange behavior in both the original and my current version: 

After saving the module to my personal library, I load with(MyPackage). Most functions work fine (all but a handful out of dozens).  However, some functions won't be recognized (e.g., Coproduct(...) will return itself Coproduct(...)).  

HOWEVER, when I execute the code in the module in its own Maple worksheet, all functions are recognized and work perfectly.  I look at the difference in the code between the functions that work upon loading the package (using with(MyPackage) command in a separate sheet) and those that don't, and there is no difference.

I'm assuming I'll just have to cut and paste the hundreds of lines of code for my package into each sheet I'd like to use it in, since I haven't been able to find others experience this problem in the knowledge base.  I'm hoping someone will be able to help out, however.

Sorry if this has been already posted.

 

When print() is invoked from a proc into a module, non-English characters are not properly displayed with Maple 18.

It works ok if it is invoked from within the workbook.

 

Example:
print("Están en perspectiva")

Put this sentence in a proc into a module and the character "á" wont be displayed

Output: "Est�n en perspectiva"

Any hint about how to treat this issue?

Thank you very much.

César Lozada 

 

 

I have a procedure that takes an object, i.e. a module, as an argument. On grounds of the properties of that object, the procedure should return a certain map. But I hit a snag, the gist of which is along the following lines (just an example):

M := module()
   export dim;
   dim := 2;
end module:

F := proc(m::`module`)
   (x::Vector(m:-dim)) -> something
end proc:

My problem is that F(M) produces

rather than

How can I force m:-dim within F to be evaluated?

I wrote the following code inside a code region in order to implement a scalar product for lists:

m:= module() option package; export `*`;
    `*`:= proc( a::list, b::list) option overload;
        return add(i, i  in zip((x, y)-> x*y, a, b));
    end proc;    
end module;
l1:=[1,2,3,4];
l2:=[4,1,0,5];
with(m);
l1*l2;

when i run the code I sometimes get the desired result ->26

but sometimes I get

I don't have any clue, where this weird behaviour comes from.

Any help would be greatly appreciated.

 

Hi everyone

I am currently trying to make my own simple package including a few procedures. So far I have been able to write some "code" that actually works when I open the document and hit "enter". I would, however, like to save the package so it can be accessed during any Maple session using the command "with". I have unsuccesfully tried to comprehend the Maple help pages regarding this question but I definitely don't want to mess things up.

This is what I have written:

mat := module ()
description "useful procedures for mathematics, physics and chemistry";
export AtomicWeight;
option package;

   AtomicWeight := proc (x) description "returns the average atomic mass of the naturally ocurring element";
   Units:-AddSystem(NewSystem, Units:-GetSystem(SI), u);
   return evalf(ScientificConstants:-Element(x, atomicweight, system = NewSystem, units))
   end proc

end module;

What should I do to save it correctly?

Thank in advance,
Mads


 

 

 

 

 

error module is maple.dll_unloaded

 

i have already called stopmaple(kv);

in

testfunction(string hello){....stopmaple(kv));

 

testfunction(1);

testfunction(2);

when call testfunction again , it got error

1 2 3 4 Page 1 of 4