I made the following package file :
BeginPackage["thermotoolpackage`"]
LLog[x_] := If[x != 0, Log[x], 0]
H2[x_] := (-x)*LLog[x] - (1 - x)*LLog[1 - x]
InvH2BrancheDroite[x_] := 1 - InverseFunction[H2][x]
EntropyMat[M_] := Module[{eigenValues, entropy},
eigenValues = Eigenvalues[M];
entropy = -Sum[
If[eigenValues[[i]] != 0, eigenValues[[i]]*Log[eigenValues[[i]]],
0], {i, Length[eigenValues]}]
]
VectToDensityMat[v_] := Module[{rho},
rho = Array[v[[#1]]*Conjugate[v[[#2]]] &, {Length[v], Length[v]}]
]
test[x_] := x + 1
EndPackage[]
The cell of this package is parametrised as "initialization cell".
In my code, I first load the package :
<< thermopackage`
But all functions excepted test are recognized. If I do test[2] it does not recognize it a a function (whereas LLog, H2 etc are recognized).
I actually just reopened this old package I made in the past and wanted to add functions (like the example test), and the recent functions I added to my package aren't recognized, and I don't get why.
They are only recognized if I first open the package and run it.
How to make it work ? Mathematica seems again very complicated for a very basic task.
<< thermopackage`
and pressing Run Package have different effects? Then<< thermopackage`
does not load the file you think it is loading. EvaluateFindFile["thermopackage`"]
to see what it loads. $\endgroup$Get["/path/to/file"]
to load a specific file. Speaking of complicated things, file lookup is complicated. mathematica.stackexchange.com/a/133275/12 I think it's a better idea to only use theGet["context`"]
syntax with packages that are properly installed in a standard location (such as$UserBaseDirctory/Applications
). $\endgroup$