source: tol/tolbase/tests/031008.tol @ 6d7779d

1941-docker-image-to-testdevel
Last change on this file since 6d7779d was 6d7779d, checked in by Jorge Pérez <josp.jorge@…>, 18 years ago

initial import

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@1 be4846ae-f051-483a-831f-b64e7d08527f

  • Property mode set to 100644
File size: 1.1 KB
Line 
1//////////////////////////////////////////////////////////////////////////////
2Real ReaPower(Real x, Real y)
3//////////////////////////////////////////////////////////////////////////////
4{
5  Case
6  (
7    EQ(y,0), 1,
8    And(EQ(x,0), GT(y,0)), 0,
9    And(EQ(x,0), LT(y,0)), 1/0,
10    And(NE(x,0), NE(y,0)), Sign(x)*(Abs(x)^y)
11  )
12};
13//////////////////////////////////////////////////////////////////////////////
14PutDescription("Calcula la potencia y de un numero x. La funcion ^ no retorna
15correctamente el valor para x <= 0 e y no entero o 0, en las versiones
161.1.8 y 1.1.9",
17ReaPower);
18//////////////////////////////////////////////////////////////////////////////
19 
20Set TestReaPower =
21{
22  Set xSet = SetOfReal(3, 0, -3);
23  Set ySet = SetOfReal(3, 4/3, 3/2, 1/2, 1/3, 0, -1/3, -1/2, -3/2, -4/3, -3);
24   
25  Set data = EvalSet(CartProd(xSet, ySet), Set(Set reg)
26  {
27    Real x = reg[1];
28    Real y = reg[2];
29 
30    Real pow = ReaPower(x,y);
31    Real ori = x^y;
32    SetOfReal(x, y, pow, ori)
33  });
34   
35  Set header = SetOfText("x", "y", "ReaPower(x, y)", "x^y");
36  SetOfSet(header)<<data
37};
Note: See TracBrowser for help on using the repository browser.