[prev in list] [next in list] [prev in thread] [next in thread] 

List:       koffice-devel
Subject:    patch for missing function
From:       Sascha Pfau <mrpeacock () gmail ! com>
Date:       2006-12-13 18:04:45
Message-ID: 200612131904.45516.MrPeacock () gmail ! com
[Download RAW message or body]

hello,

i am very new to koffice. i've take a look into your todo's. i think 
implementing missing function isn't very difficult. so i sat down ans wrote 
IMLOG2 and IMLOG10 functioncs, but now i don't know about how to commit my 
patch.

i hope you take a look at it and commit it to trunk.

greetings

Sascha Pfau

["kspread-add-math.patch" (text/x-diff)]

--- ./engineering.cpp.org	2006-12-10 11:52:22.000000000 +0100
+++ ./engineering.cpp	2006-12-13 12:01:11.000000000 +0100
@@ -64,6 +64,8 @@
 Value func_imdiv (valVector args, ValueCalc *calc, FuncExtra *);
 Value func_imexp (valVector args, ValueCalc *calc, FuncExtra *);
 Value func_imln (valVector args, ValueCalc *calc, FuncExtra *);
+Value func_imlog2 (valVector args, ValueCalc *calc, FuncExtra *);
+Value func_imlog10 (valVector args, ValueCalc *calc, FuncExtra *);
 Value func_impower (valVector args, ValueCalc *calc, FuncExtra *);
 Value func_improduct (valVector args, ValueCalc *calc, FuncExtra *);
 Value func_imsin (valVector args, ValueCalc *calc, FuncExtra *);
@@ -149,6 +151,10 @@
   repo->add (f);
   f = new Function ("IMLN",        func_imln);
   repo->add (f);
+  f = new Function ("IMLOG2",        func_imlog2);
+  repo->add (f);
+  f = new Function ("IMLOG10",        func_imlog10);
+  repo->add (f);
   f = new Function ("IMPOWER",     func_impower);
   f->setParamCount (2);
   repo->add (f);
@@ -1133,6 +1139,57 @@
   return Value (tmp);
 }
 
+// Function: IMLOG2
+Value func_imlog2 (valVector args, ValueCalc *calc, FuncExtra *)
+{
+  QString tmp = calc->conv()->asString (args[0]).asString();
+  bool ok;
+  double real=real_complexe(tmp,ok);
+  if(!ok)
+    return Value::errorVALUE();
+  double imag=imag_complexe(tmp,ok);
+  if(!ok)
+    return Value::errorVALUE();
+
+  double arg=sqrt(pow(imag,2)+pow(real,2));
+  double real_res=log(arg)*M_LOG2El;
+  double imag_res=atan(imag/real)*M_LOG2El;
+  
+  tmp=func_create_complex(real_res,imag_res);
+
+  double result=KGlobal::locale()->readNumber(tmp, &ok);
+  if(ok)
+    return Value (result);
+
+  return Value (tmp);
+}
+
+// Function: IMLOG10
+Value func_imlog10 (valVector args, ValueCalc *calc, FuncExtra *)
+{
+  QString tmp = calc->conv()->asString (args[0]).asString();
+  bool ok;
+  double real=real_complexe(tmp,ok);
+  if(!ok)
+    return Value::errorVALUE();
+  double imag=imag_complexe(tmp,ok);
+  if(!ok)
+    return Value::errorVALUE();
+
+  double arg=sqrt(pow(imag,2)+pow(real,2));
+  double real_res=log(arg)*M_LOG10El;
+  double imag_res=atan(imag/real)*M_LOG10El;
+  
+  tmp=func_create_complex(real_res,imag_res);
+
+  double result=KGlobal::locale()->readNumber(tmp, &ok);
+  if(ok)
+    return Value (result);
+
+  return Value (tmp);
+}
+
+
 // Function: IMEXP
 Value func_imexp (valVector args, ValueCalc *calc, FuncExtra *)
 {
--- ./engineering.xml.org	2006-12-10 11:52:22.000000000 +0100
+++ ./engineering.xml	2006-12-13 16:57:11.000000000 +0100
@@ -475,6 +475,34 @@
     </Function>
 
     <Function>
+      <Name>IMLOG2</Name>
+      <Type>String</Type>
+      <Parameter>
+	<Comment>Complex number</Comment>
+	<Type>String</Type>
+      </Parameter>
+      <Help>
+	<Text>The IMLOG2(string) returns the base-2 logarithm of a complex number.</Text>
+	<Syntax>IMLOG2(string)</Syntax>
+	<Example>IMLOG2("3+4i") returns "2.321928+1.337804i"</Example>
+      </Help>
+    </Function>
+
+    <Function>
+      <Name>IMLOG10</Name>
+      <Type>String</Type>
+      <Parameter>
+	<Comment>Complex number</Comment>
+	<Type>String</Type>
+      </Parameter>
+      <Help>
+	<Text>The IMLOG10(string) returns the base-10 logarithm of a complex number.</Text>
+	<Syntax>IMLOG10(string)</Syntax>
+	<Example>IMLOG10("3+4i") returns "0.69897+0.402719i"</Example>
+      </Help>
+    </Function>
+
+    <Function>
       <Name>IMSQRT</Name>
       <Type>String</Type>
       <Parameter>


_______________________________________________
koffice-devel mailing list
koffice-devel@kde.org
https://mail.kde.org/mailman/listinfo/koffice-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic