Question: Using the export of a module in another one

Hi

Some time ago I started to write my own modules.
I've a problem with a module calling an export of another one. Both have the "package" option.

The first module, Math_Tools_ex export a "diffindice" procedure. I copy here the relevant part of the code:


####################################
Math_Tools_ex:=module()

export diffindice, doublederivcov,Dimensione,mix, Test_Symmetry, Double_dag ;
export Coords,A,M,G, Abstraction;
global X, c, dimensione,abstraction;

local temp, setup;


option
package,
load=setup;

setup:=proc()
dimensione:=6;
X:=[t,r,theta,phi];
abstraction:=3;
assume(c, 'constant'):
 additionally(c, 'numeric'):
with(LinearAlgebra);
end proc;

diffindice := proc (Z, mu)
global abstraction;
fattore:=[c, 1, 1, 1]:
return diff(Z, X[mu])/fattore[mu]
end proc:

etc etc
end module:
savelib('Math_Tools_ex'):
########################

Then the other module, Phys_Quant_ex_0, imports the exports of the first one, via the "with(packageName)" sintax, and uses the diffindice procedure to calculate an Array metricabassa_0 (all lowercase) when one call the "costructor" MetricaBassa_0. Here the code:

###################################
Phys_Quant_ex_0:=module()

export Eta,MetricaAlta_0, MetricaBassa_0,Chris_0,Chris_ex_0, Riemann_0, Ricci_0,Curvature_0, Einstein_0;
local i, Startup;
global X,eta,dimensione, Doublez_0, z_0,metricabassa_0, metricaalta_0, riemann_0, chris_0,ricci_0,curvature_0, einstein_0;

option package:

with(LinearAlgebra);
with(Math_Tools_ex);

Eta:=proc()
eta:= Array(1..dimensione,1..dimensione);
eta[1,1]:=1;
for i from 2 to dimensione do
eta[i,i]:=-1;
end do;
end proc:


MetricaBassa_0:= proc()
local temp;
  temp:=Array(1..4,1..4, (i,j)-> add(eta[q,q]*'diffindice'(z_0(X[])[q],i)*'diffindice'(z_0(X[])[q],j), q=1..dimensione));
metricabassa_0:=unapply(Array(1..4,1..4, (i,j)->simplify(eval(temp[i,j]))),X[]);
end proc:

etc etc
end module:
savelib('Phys_Quant_ex_0'):
###################################

the problem arises when I use these packages in a Worksheet. In fact, MetricaBassa_0() returns to me a result with unevaluated diffindice. Something like:


#################################
restart;
with(Math_Tools_ex);
   [A, Abstraction, Coords, Dimensione, Double_dag, G, M, Test_Symmetry, diffindice, doublederivcov, mix]
with(Phys_Quant_ex_0);
     [Chris_0, Chris_ex_0, Curvature_0, Einstein_0, Eta, MetricaAlta_0, MetricaBassa_0, Ricci_0, Riemann_0]

### define z_0 and Delta(r)

Delta:=proc(r) r^2 -2*M*G*r+Q^2 end proc:

z_0 := unapply(Array(1 .. dimensione,[
lambda*sqrt(Delta(X[2])/(X[2])^2)*sinh(c*X[1]/lambda),
lambda*sqrt(Delta(X[2])/(X[2])^2)*cosh(c*X[1]/lambda),
Int(sqrt((-y^2+2*M*G*y-Q^2)*(lambda^2*Q^4-2*y^5*M*G+lambda^2*M^2*G^2*y^2+y^4*Q^2-2*lambda^2*M*G*y*Q^2))/((-y^2+2*M*G*y-Q^2)*y^2), y=0..X[2]),
X[2]*sin(X[3])*sin(X[4]),
X[2]*cos(X[4])*sin(X[3]),
X[2]*cos(X[3])
,0
,0
]),X[]):

MetricaBassa_0():

simplify(metricabassa_0(X[])[1,2]);

-diffindice(r*sin(theta)*sin(phi), 1)*diffindice(r*sin(theta)*sin(phi), 2)-diffindice(r*cos(phi)*sin(theta), 1)*diffindice(r*cos(phi)*sin(theta), 2) ... (OTHER TERMS)
##########################################

It seems that the MetricaBassa_0 procedure in my module don't  knows what diffindice procedure is (even if I used "with(Math_Tools_ex)" in the module).

However the global worksheet knows diffindice: if I write

#########
diffindice(r*sin(theta)*sin(phi), 2);
                             sin(theta) sin(phi)
#########

it gives the correct answer. Nevertheless if I try:

eval(metricabassa_0(X[])[1,2])

it lets the diffindice procedures unevaluated.

I tried to debug that procedure with the stopat method. It seems that some problem exist, as I get, in the debbuger page:

######################
MetricaBassa_0:
   1*  temp := Array(1 .. 4,1 .. 4,(i, j) -> add(eta[q,q]*('diffindice')(z_0(X[])[q],i)*('diffindice')(z_0(X[])[q],j),q = 1 .. dimensione));
============================================
`unknown/9A8CE78`:
   1   add(eta[q,q]*('diffindice')(z_0(X[])[q],i)*('diffindice')(z_0(X[])[q],j),q = 1 .. dimensione)
============================================

#################

this "unknown/9A8CE78" might be linked with the problem.
I tried to use diffindice inside the debbuger page, and it "knows" what it is.

Finally, if I try not tu use the with(Math_Tools_ex) sintax in my second module, but instead:


################################
Phys_Quant_ex_0:=module()

local ...
global ...
export ...
options ...

use Math_Tools_ex in

module body

end use

end module:
#################################

MetricaBassa_0 works: it returns the evaluated calls to diffindice.

So, my questions are:

1) Why "with(PackageName)" seems not working when used in another package/module? Is it a general law or I did something odd?
2) If diffindice is known in the global session (and it is known!!!) why eval can't use this knowledge to simplify metricabassa_0?


I hope my problem is clear (isn't obvious to explain it!).
I thank in advance, and I'm here if you need more input/output or details

Thank you

S.V.

Please Wait...