summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-sheet/sheet.cpp
Side-by-side diff
Diffstat (limited to 'noncore/apps/opie-sheet/sheet.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/opie-sheet/sheet.cpp122
1 files changed, 85 insertions, 37 deletions
diff --git a/noncore/apps/opie-sheet/sheet.cpp b/noncore/apps/opie-sheet/sheet.cpp
index 88847da..477c982 100644
--- a/noncore/apps/opie-sheet/sheet.cpp
+++ b/noncore/apps/opie-sheet/sheet.cpp
@@ -1,11 +1,30 @@
-/***************************************************************************
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
+/*
+ =. This file is part of the Opie Project
+ .=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org>
+ .>+-=
+ _;:, .> :=|. This program is free software; you can
+.> <`_, > . <= redistribute it and/or modify it under
+:`=1 )Y*s>-.-- : the terms of the GNU General Public
+.="- .-=="i, .._ License as published by the Free Software
+ - . .-<_> .<> Foundation; either version 2 of the License,
+ ._= =} : or (at your option) any later version.
+ .%`+i> _;_.
+ .i_,=:_. -<s. This program is distributed in the hope that
+ + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
+ : .. .:, . . . without even the implied warranty of
+ =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
+ _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.= = ; Library General Public License for more
+++= -. .` .: details.
+ : = ...= . :.=-
+ -. .:....=;==+<; You should have received a copy of the GNU
+ -_. . . )=. = Library General Public License along with
+ -- :-=` this library; see the file COPYING.LIB.
+ If not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+*/
/*
* Opie Sheet (formerly Sheet/Qt)
@@ -14,7 +33,10 @@
#include "sheet.h"
+/* QT */
#include <qmessagebox.h>
+
+/* STD */
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
@@ -48,8 +70,7 @@ Sheet::Sheet(int numRows, int numCols, QWidget *parent)
}
Sheet::~Sheet()
-{
-}
+{}
typeCellData *Sheet::findCellData(int row, int col)
{
@@ -67,7 +88,8 @@ void Sheet::slotCellSelected(int row, int col)
if (cellData)
{
emit currentDataChanged(cellData->data);
- }else
+ }
+ else
emit currentDataChanged("");
}
@@ -228,7 +250,8 @@ double Sheet::BesselI0(double x)
y=x/3.75;
y*=y;
ans=1.0+y*(3.5156229+y*(3.0899424+y*(1.2067492 +y*(0.2659732+y*(0.360768e-1+y*0.45813e-2)))));
- }else
+ }
+ else
{
y=3.75/ax;
ans=(exp(ax)/sqrt(ax))*(0.39894228+y*(0.1328592e-1 +y*(0.225319e-2+y*(-0.157565e-2+y*(0.916281e-2 +y*(-0.2057706e-1+y*(0.2635537e-1+y*(-0.1647633e-1 +y*0.392377e-2))))))));
@@ -245,7 +268,8 @@ double Sheet::BesselI1(double x)
y=x/3.75;
y*=y;
ans=ax*(0.5+y*(0.87890594+y*(0.51498869+y*(0.15084934 +y*(0.2658733e-1+y*(0.301532e-2+y*0.32411e-3))))));
- } else
+ }
+ else
{
y=3.75/ax;
ans=0.2282967e-1+y*(-0.2895312e-1+y*(0.1787654e-1 -y*0.420059e-2)); ans=0.39894228+y*(-0.3988024e-1+y*(-0.362018e-2 +y*(0.163801e-2+y*(-0.1031555e-1+y*ans))));
@@ -292,7 +316,8 @@ double Sheet::BesselK0(double x)
{
y=x*x/4.0;
ans=(-log(x/2.0)*BesselI0(x))+(-0.57721566+y*(0.42278420 +y*(0.23069756+y*(0.3488590e-1+y*(0.262698e-2 +y*(0.10750e-3+y*0.74e-5))))));
- } else
+ }
+ else
{
y=2.0/x;
ans=(exp(-x)/sqrt(x))*(1.25331414+y*(-0.7832358e-1 +y*(0.2189568e-1+y*(-0.1062446e-1+y*(0.587872e-2 +y*(-0.251540e-2+y*0.53208e-3))))));
@@ -307,7 +332,8 @@ double Sheet::BesselK1(double x)
{
y=x*x/4.0;
ans=(log(x/2.0)*BesselI1(x))+(1.0/x)*(1.0+y*(0.15443144 +y*(-0.67278579+y*(-0.18156897+y*(-0.1919402e-1 +y*(-0.110404e-2+y*(-0.4686e-4)))))));
- } else
+ }
+ else
{
y=2.0/x;
ans=(exp(-x)/sqrt(x))*(1.25331414+y*(0.23498619 +y*(-0.3655620e-1+y*(0.1504268e-1+y*(-0.780353e-2 +y*(0.325614e-2+y*(-0.68245e-3)))))));
@@ -342,7 +368,8 @@ double Sheet::BesselJ0(double x)
ans1=57568490574.0+y*(-13362590354.0+y*(651619640.7 +y*(-11214424.18+y*(77392.33017+y*(-184.9052456)))));
ans2=57568490411.0+y*(1029532985.0+y*(9494680.718 +y*(59272.64853+y*(267.8532712+y*1.0))));
ans=ans1/ans2;
- } else
+ }
+ else
{
z=8.0/ax;
y=z*z;
@@ -364,7 +391,8 @@ double Sheet::BesselY0(double x)
ans1 = -2957821389.0+y*(7062834065.0+y*(-512359803.6 +y*(10879881.29+y*(-86327.92757+y*228.4622733))));
ans2=40076544269.0+y*(745249964.8+y*(7189466.438 +y*(47447.26470+y*(226.1030244+y*1.0))));
ans=(ans1/ans2)+0.636619772*BesselJ0(x)*log(x);
- } else
+ }
+ else
{
z=8.0/x;
y=z*z;
@@ -386,7 +414,8 @@ double Sheet::BesselJ1(double x)
ans1=x*(72362614232.0+y*(-7895059235.0+y*(242396853.1 +y*(-2972611.439+y*(15704.48260+y*(-30.16036606))))));
ans2=144725228442.0+y*(2300535178.0+y*(18583304.74 +y*(99447.43394+y*(376.9991397+y*1.0))));
ans=ans1/ans2;
- } else
+ }
+ else
{
z=8.0/ax; y=z*z; xx=ax-2.356194491;
ans1=1.0+y*(0.183105e-2+y*(-0.3516396496e-4 +y*(0.2457520174e-5+y*(-0.240337019e-6))));
@@ -407,7 +436,8 @@ double Sheet::BesselY1(double x)
ans1=x*(-0.4900604943e13+y*(0.1275274390e13 +y*(-0.5153438139e11+y*(0.7349264551e9 +y*(-0.4237922726e7+y*0.8511937935e4)))));
ans2=0.2499580570e14+y*(0.4244419664e12 +y*(0.3733650367e10+y*(0.2245904002e8 +y*(0.1020426050e6+y*(0.3549632885e3+y)))));
ans=(ans1/ans2)+0.636619772*(BesselJ1(x)*log(x)-1.0/x);
- } else
+ }
+ else
{
z=8.0/x;
y=z*z;
@@ -458,7 +488,8 @@ double Sheet::BesselJ(int n, double x)
bj=bjp;
}
ans=bj;
- } else
+ }
+ else
{
tox=2.0/ax;
m=2*((n+(int) sqrt(ACC*n))/2);
@@ -518,7 +549,8 @@ double Sheet::GammaP(double a, double x)
{
GammaSeries(&gamser,a,x,&gln);
return gamser;
- }else
+ }
+ else
{
GammaContinuedFraction(&gammcf,a,x,&gln);
return 1.0-gammcf;
@@ -544,7 +576,8 @@ void Sheet::GammaSeries(double *gamser, double a, double x, double *gln)
if (x < 0.0) return;//error
*gamser=0.0;
return;
- } else
+ }
+ else
{
ap=a;
del=sum=1.0/a;
@@ -558,7 +591,8 @@ void Sheet::GammaSeries(double *gamser, double a, double x, double *gln)
*gamser=sum*exp(-x+a*log(x)-(*gln));
return;
}
- } return;
+ }
+ return;
return;
}
};
@@ -662,7 +696,8 @@ double Sheet::functionSum(const QString &param1, const QString &param2)
if (ok) result+=tempResult;
}
return result;
- }else
+ }
+ else
{
double d1=0,d2=0;
d1=calculateVariable(param1).toDouble(&ok);
@@ -789,7 +824,8 @@ double Sheet::functionSumSQ(const QString &param1, const QString &param2)
if (ok) result+=tempResult*tempResult;
}
return result;
- }else
+ }
+ else
{
double d1=0,d2=0;
d1=calculateVariable(param1).toDouble(&ok);
@@ -819,7 +855,8 @@ double Sheet::functionMin(const QString &param1, const QString &param2)
}
}
return min;
- }else
+ }
+ else
{
double d1=0,d2=0;
d1=calculateVariable(param1).toDouble(&ok);
@@ -847,7 +884,8 @@ double Sheet::functionMax(const QString &param1, const QString &param2)
}
};
return max;
- }else
+ }
+ else
{
double d1=0,d2=0;
d1=calculateVariable(param1).toDouble(&ok);
@@ -877,7 +915,8 @@ double Sheet::functionCount(const QString &param1, const QString &param2)
if (ok) ++divider;
};
return divider;
- }else
+ }
+ else
{
double d1=0,d2=0;int ii=0;
d1=calculateVariable(param1).toDouble(&ok);
@@ -992,12 +1031,14 @@ QString Sheet::calculateFunction(const QString &func, const QString &parameters,
if(findRowColumn(getParameter(parameters, 0), &row, &col, FALSE))
{
if(text(row,col).length()==0) val1=1; else val1=0;
- }else
+ }
+ else
{
if(findRowColumn(calculateVariable(getParameter(parameters, 0)), &row,&col, FALSE))
{
if(text(row,col).length()==0) val1=1; else val1=0;
- }else
+ }
+ else
{
val1=0;
};
@@ -1012,13 +1053,15 @@ QString Sheet::calculateFunction(const QString &func, const QString &parameters,
{
val1=text(row,col).toDouble(&ok);
if(ok) val1=1; else val1=0;
- }else
+ }
+ else
{
if(findRowColumn(calculateVariable(getParameter(parameters, 0, TRUE, function)), &row,&col, FALSE))
{
val1=text(row,col).toDouble(&ok);
if(ok) val1=1; else val1=0;
- }else
+ }
+ else
{
val1=0;
};
@@ -1389,7 +1432,8 @@ QString Sheet::calculateFunction(const QString &func, const QString &parameters,
{
s1=calculateVariable(getParameter(parameters, 1, TRUE, function));
return QString(s1);
- }else
+ }
+ else
{
s1=calculateVariable(getParameter(parameters, 2, TRUE, function));
return QString(s1);
@@ -1552,7 +1596,8 @@ QString Sheet::calculateFunction(const QString &func, const QString &parameters,
if(vali==1)
{
return QString::number(GammaQ(floor(val1)+1, val2));
- }else
+ }
+ else
{
return QString::number(exp(-val2)*pow(val2,val1)/exp(GammaLn(val1+1.0)));
};
@@ -1566,7 +1611,8 @@ QString Sheet::calculateFunction(const QString &func, const QString &parameters,
if(vali==1)
{
return QString::number(GammaP(val2/2.0,val1*val1/2.0));
- } else
+ }
+ else
{
return QString::number(
pow(val1,val2-1.0)*exp(-val1*val1/2)/ ( pow(2,val2/2.0-1.0)*exp(GammaLn(val2/2.0)))
@@ -1582,7 +1628,8 @@ QString Sheet::calculateFunction(const QString &func, const QString &parameters,
if(vali==1)
{
return QString::number(GammaP(val2/2.0,val1/2.0));
- } else
+ }
+ else
{
return QString::number(
pow(val1,val2/2.0-1.0)/(exp(val1/2.0)*pow(sqrt(2.0),val2)*exp(GammaLn(val2/2.0)))
@@ -2385,7 +2432,8 @@ void Expression::GetNext()
}
}//while
}//else if
-};//end function
+}
+;//end function
void Expression::First()