Items tagged with package package Tagged Items Feed

Mytest:=module()
    option package;
    
    export
        mymain
        ;
        
        
    # local a,b,c;

    uses LinearAlgebra;
    
    interface(rtablesize=infinity);
    
    
    mymain:=proc(n::integer)

        local ans;
        
        ans:=Vector(n);

        return ans;

    end proc;

end module;

Here is a short piece of code to create a Maple package. It runs fine. Is that possible to hide the code from print() ?

 

with(Mytest);

print(mymain); # which displays the source code

 

Could I hide some of the code? Say I want to use the function mymain() for debugging purpose, but I dont want to make it local to the package. Instead I keep it in "export", but I dont want users to see its code.

 

Thanks!

@ecterrab 

I figured I'd start a new thread for odd things I come across whilst using the new physics package. 

I have found this, and am not sure if it is expected. 

 


restart

with(Physics):

Setup(mathematicalnotation = true):

``

Setup(Commutator(Psigma[i], Psigma[j]) = Physics:-`*`(Physics:-`*`(I, ep_[i, j, k]), Psigma[k]), AntiCommutator(Psigma[i], Psigma[j]) = Physics:-`*`(2, kd_[i, j]));

[algebrarules = {%AntiCommutator(Physics:-Psigma[i], Physics:-Psigma[j]) = 2*Physics:-KroneckerDelta[i, j], %Commutator(Physics:-Psigma[i], Physics:-Psigma[j]) = I*Physics:-LeviCivita[i, j, k]*Physics:-Psigma[k]}]

(1)

NULL

Psigma[1].Psigma[1]

Physics:-Psigma[1]^2

(2)

Simplify(%)

Physics:-Psigma[1]^2

(3)

Simplify(Physics:-Psigma[1]^2)

1

(4)

``


Download Simplify2.mw

I have to calculate the data in JSON format and export the result back to JSON.

It would be greate if there is any JSON package for Maple.
---

Also, I use`ExportMatrix` to export the result to CSV format.

But there are some comma (`,`) in the result content and `ExportMatrix` does not handle it well.
Is there any solution for export data to CSV file in my situation?

Thanks.

 

I am Maple 15 student edition user and the packages is not loaded when I use the execute all command from the GUI. I have to manually press the enter key to have by package loaded before I use a function defined in the package. How can I work around this issue?

Thanks

P.S: You can see the Maple document attached to this post.

NumericalSimulation.mw

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

Hi all,

I created a package and saved it already. I checked and found it at D:/CaoHoc/LuanVan/Code/workspace/HINHHOC9.m but when I load it using with command, it has error.

[.............Code to create package..............]

>url := currentdir();
                   url := "D:\CaoHoc\LuanVan\Code\workspace"

>
>save HINHHOC9, cat(url, "/HINHHOC9.m");
>
>libname := libname, url;
libname := "C:\Program Files\Maple 18\lib",

    "D:\CaoHoc\LuanVan\Code\workspace\LuanVan\binaries",

    "C:\Program Files\Maple 18\lib", "D:\CaoHoc\LuanVan\Code\workspace"

>
>         with(HINHHOC9);
Error, (in with) user level initialization for package `HINHHOC9' failed: file
or directory does not exist

Please help me to identify the problem. Thanks

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?

 

In Maple, I seem to keep finding commands in different Maple build-in packages that does the same thing. Which is very confusing for someone trying to learn Maple.

Maple seems to have good things in it, but at the same time, it strikes me as a large bag with lots of tools and commands thrown in with little sense of coherence. One needs one command from one package to finish the job started using a command from a different package, and an option from one place to patch something done with a command from another package.

Here is one example. I wanted to obtain the diagonal of a matrix. So far, I found 3 commands that do the same exact thing:

A:=Matrix([ [1,2,3],[4,5,6],[7,8,9]]);
MTM:-diag(A);  #1
LinearAlgebra:-Diagonal(A);  #2
Student:-LinearAlgebra:-Diagonal(A);  #3

I am sure if continue to look, I might find another command to do the same thing hiding in some other package.

The problem for new user like me, is how does one decide which comand to use. This is the same as with constructing a Matrix. There is the Matrix([[]]) notation and metod, and there is the <<>> notation that does the same thing but with different and conflicting syntax.

Having many commands that do duplicate things is not a good thing at all. Commands should be axiomatic and orthogonal to each others. I think there should be a document that describes from a high level all these packages, may be as a block diagram with arrows that show the relation, if any, between them, and how they interact and when to use one vs. the other.

Is there a reason for this duplication of functionality? Does any one at Maplesoft look at such issues?

 

I do not like to load a package using with() and then use its commands and functions, since I then lose track knowing from which package a function or command being used in the code came from when I look at the code later on. So I like to write

pkg:-f() or pkg[f]() instead of with(pkg); f()

This seems to work most of the time, except I just found a case where I am forced to do with(pkg) at the top. Here is the example. I'd like to know if there is a workaround where I can avoid with(pkg) in this case as well:

restart;
f:=t->piecewise(t<0,0,t>=0 and t<z,t,t>z,z):
r:=convert(f(t),Heaviside):
r:=inttrans[laplace](r,t,s);


Now since Maple does not know what z is, it could not fully evaluate the result above (I can handle this with assumptions, but this is just an example). So now I replaced z by 0.5, but since laplace is not loaded, it still could not do it:

r:=subs(z=0.5,r);

So now I had to load the package, just to simply the above expression:

with(inttrans);
r;

This all becuase the expression earlier was left with only "laplace" in it, and not "inttrans[laplace]" as I typed. (why this happend, I do not know).

My question is: How would you do the above, without loading the package? I really do not like loading packages as I said, and like to keep the name of the package attached to each function to help me know where each function is coming from.

 

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.

Panel method package...

July 02 2014 Fab 5

Hi Maple users :)

do you know if exists a Maple package in order to perform a Panel method, for instance in the Hess-Smith version, for solving incompressible potential flow over thick 2d and 3d airfoil geometries?

Thank in advance for the help.

Take a look at this link.

Hi,

I have been looking at some new models of Casio Scientific Calculators and came across with "Fx-115es Plus" Model which seem to have a some sort of simple CAS(Computer Algebra System) built into it.


Two new features which i really liked were

(i) Ability to make any part of the expression inert and simplying the rest.

(ii) Fully Integrated Repeated decimal display for fractions.

 

I want to ask if there is any builtin commands that can achieve these two effects in maple.

I will give some example for each of these

(i) simplifying say 2^3*2^4 in maple gives 32.

but forexample if i want to make 2 in the bases inert then simplifying the result should give 2^7

if i make 3 inert then the result is 16*2^3

if i make 4 inert then the result is 8*2^4

another example say (2^3)^4 in maple gives 4096

but if i make 2 inert then the result should be 2^12

if i make 3 inert then the result is 16^3

if i make 4 inert then the result is 8^4

In this way it is possible to keep any interesting part of large complex expression unevaluated and simplifying the rest across it to maintain focus on the interesting part.

I know i can try to achieve this effect by using unevaluation quotes but they get messy and harder to track in large nested forms.

Another approach might be to replace the inert parts by explicit undeclared symbols with required assumptions and simplifying, but this is not it.

I know in Maple 18 they have introduced some package called InertForm or something, can it achieve this effect and also mark inert parts of the expression as grey like it is possible for some operators.

(ii) the example for the second is quite obvious, say given the fraction 237/14, evalf of this gives 16.92857143 but a result like 16.9Overscript[285714, _] is more closer to differentiation it from a irrational expansion. Sorry i donot know how to pretty print this here.

Another advantage is when i want to give some large repeating decimal expansion and have maple convert it to fractional form. Currently i have no idea how many times to repeat the decimals explicitly to make maple understand that it is a repeating decimal expansion.

I often use RegularChains and SolveTools package. SemiAlgebraic is extremelly useful to deal with polynomial equations. However, I need some similar to Mathematica's Resolve that allows me to eliminate some variables from the description of the set. Say we have some set decribed by: for all 0<x<1, p(x,z)> 0 where p is a polynomial in x and z. Is there any Maple command that allow us to remove x and give the set only n terms of z?

Hello: I'm looking over the Help section but I can not find a Maple package that has a command to compute the symmetric sum or the cyclic sum. I just started working with inequalities. Please could anyone recommend a package that allows me to compute expressions related to Muirhead's Inequality (see part 2 of  the answer:  http://math.stackexchange.com/questions/488967/majorization-muirhead)

1 2 3 4 5 6 7 Last Page 1 of 31