[gcalctool] Update Czech translation by Marek Cernocky
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gcalctool] Update Czech translation by Marek Cernocky
- Date: Mon, 24 May 2010 01:42:16 +0000 (UTC)
commit 0f2cb1c401d3213786b8b1f87b903cf9bae6b730
Author: Petr Kovar <pknbe volny cz>
Date: Sun May 23 19:33:09 2010 +0200
Update Czech translation by Marek Cernocky
NEWS | 8 ++++
src/mp-convert.c | 17 ++++++---
src/mp-trigonometric.c | 19 +---------
src/mp.c | 92 +++++++++++++++++++++++++++++++++--------------
src/unittest.c | 18 ++++++----
5 files changed, 96 insertions(+), 58 deletions(-)
---
diff --git a/NEWS b/NEWS
index 1aa4e8b..34d95df 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,14 @@
* All Rights Reserved.
*/
+Overview of changes in gcalctool 5.31.2
+
+ * Replace backspace button with undo button
+
+ * Remove memory buttons from basic mode (too complex)
+
+ * Support complex arithmetic
+
Overview of changes in gcalctool 5.31.1
* Dynamically load button layouts to speed up startup time
diff --git a/src/mp-convert.c b/src/mp-convert.c
index e824fb5..8964a77 100644
--- a/src/mp-convert.c
+++ b/src/mp-convert.c
@@ -258,11 +258,13 @@ mp_set_from_fraction(int64_t numerator, int64_t denominator, MPNumber *z)
void
mp_set_from_polar(const MPNumber *r, MPAngleUnit unit, const MPNumber *theta, MPNumber *z)
{
- MPNumber sin_theta, cos_theta;
-
- mp_sin(theta, unit, &sin_theta);
- mp_cos(theta, unit, &cos_theta);
- mp_set_from_complex(&cos_theta, &sin_theta, z);
+ MPNumber x, y;
+
+ mp_cos(theta, unit, &x);
+ mp_multiply(&x, r, &x);
+ mp_sin(theta, unit, &y);
+ mp_multiply(&y, r, &y);
+ mp_set_from_complex(&x, &y, z);
}
@@ -620,7 +622,10 @@ mp_cast_to_string(const MPNumber *x, int default_base, int base, int accuracy, b
s = g_string_sized_new(buffer_length);
mp_cast_to_string_real(&x_im, default_base, 10, accuracy, trim_zeroes, force_sign, s);
- if (strcmp(s->str, "1") == 0) {
+ if (strcmp(s->str, "0") == 0 || strcmp(s->str, "+0") == 0 || strcmp(s->str, "â??0") == 0) {
+ /* Ignore */
+ }
+ else if (strcmp(s->str, "1") == 0) {
g_string_append(string, "i");
}
else if (strcmp(s->str, "+1") == 0) {
diff --git a/src/mp-trigonometric.c b/src/mp-trigonometric.c
index 985475d..0297545 100644
--- a/src/mp-trigonometric.c
+++ b/src/mp-trigonometric.c
@@ -157,7 +157,7 @@ mpsin1(const MPNumber *x, MPNumber *z, int do_sin)
void
mp_sin(const MPNumber *x, MPAngleUnit unit, MPNumber *z)
{
- int ie, xs;
+ int xs;
float rx = 0.0;
MPNumber x_radians;
@@ -170,15 +170,10 @@ mp_sin(const MPNumber *x, MPAngleUnit unit, MPNumber *z)
convert_to_radians(x, unit, &x_radians);
xs = x_radians.sign;
- ie = abs(x_radians.exponent);
- if (ie <= 2)
- rx = mp_cast_to_float(&x_radians);
-
mp_abs(&x_radians, &x_radians);
/* USE MPSIN1 IF ABS(X) <= 1 */
- if (mp_compare_mp_to_int(&x_radians, 1) <= 0)
- {
+ if (mp_compare_mp_to_int(&x_radians, 1) <= 0) {
mpsin1(&x_radians, z, 1);
}
/* FIND ABS(X) MODULO 2PI */
@@ -226,16 +221,6 @@ mp_sin(const MPNumber *x, MPAngleUnit unit, MPNumber *z)
}
z->sign = xs;
-
- /* CHECK THAT ABSOLUTE ERROR LESS THAN 0.01 IF ABS(X) <= 100
- * (IF ABS(X) IS LARGE THEN SINGLE-PRECISION SIN INACCURATE)
- */
- if (ie <= 2 && fabs(rx) <= 100.0) {
- float ry = mp_cast_to_float(z);
- /* THE FOLLOWING MESSAGE MAY INDICATE THAT B**(T-1) IS TOO SMALL. */
- if (fabs(ry - sin(rx)) >= 0.01)
- mperr("*** ERROR OCCURRED IN MPSIN, RESULT INCORRECT ***");
- }
}
diff --git a/src/mp.c b/src/mp.c
index f8582a4..73843e5 100644
--- a/src/mp.c
+++ b/src/mp.c
@@ -48,7 +48,8 @@ mperr(const char *format, ...)
}
-const char *mp_get_error()
+const char *
+mp_get_error()
{
return mp_error;
}
@@ -141,8 +142,7 @@ mp_abs(const MPNumber *x, MPNumber *z)
void
mp_arg(const MPNumber *x, MPAngleUnit unit, MPNumber *z)
{
- MPNumber x_real, x_im, t;
- bool invert;
+ MPNumber x_real, x_im, pi;
if (mp_is_zero(x)) {
/* Translators: Error display when attempting to take argument of zero */
@@ -153,24 +153,35 @@ mp_arg(const MPNumber *x, MPAngleUnit unit, MPNumber *z)
mp_real_component(x, &x_real);
mp_imaginary_component(x, &x_im);
+ mp_get_pi(&pi);
- if (mp_is_zero(&x_real)) {
- mp_get_pi(z);
- convert_from_radians(z, unit, z);
- mp_divide_integer(z, 2, z);
- invert = mp_is_negative(&x_im);
+ if (mp_is_zero(&x_im)) {
+ if (mp_is_negative(&x_real))
+ convert_from_radians(&pi, MP_RADIANS, z);
+ else
+ mp_set_from_integer(0, z);
}
- else {
- mp_divide(&x_im, &x_real, &t);
- mp_atan(&t, unit, z);
- invert = mp_is_negative(&x_real);
+ else if (mp_is_zero(&x_real)) {
+ mp_set_from_mp(&pi, z);
+ if (mp_is_negative(&x_im))
+ mp_divide_integer(z, -2, z);
+ else
+ mp_divide_integer(z, 2, z);
}
-
- if (invert) {
- mp_get_pi(&t);
- convert_from_radians(&t, unit, &t);
- mp_add(z, &t, z);
+ else if (mp_is_negative(&x_real)) {
+ mp_divide(&x_im, &x_real, z);
+ mp_atan(z, MP_RADIANS, z);
+ if (mp_is_negative(&x_im))
+ mp_subtract(z, &pi, z);
+ else
+ mp_add(z, &pi, z);
+ }
+ else {
+ mp_divide(&x_im, &x_real, z);
+ mp_atan(z, MP_RADIANS, z);
}
+
+ convert_from_radians(z, unit, z);
}
@@ -1038,7 +1049,7 @@ mp_epowy(const MPNumber *x, MPNumber *z)
if (mp_is_complex(x)) {
MPNumber x_real, r, theta;
-
+
mp_real_component(x, &x_real);
mp_imaginary_component(x, &theta);
@@ -1240,13 +1251,13 @@ mp_ln(const MPNumber *x, MPNumber *z)
}
/* ln(-x) complex */
- // TEMP: Remove when supporting complex numbers
- if (mp_is_negative(x)) {
- /* Translators: Error displayed attempted to take logarithm of negative value */
+ /* FIXME: Make complex numbers optional */
+ /*if (mp_is_negative(x)) {
+ // Translators: Error displayed attempted to take logarithm of negative value
mperr(_("Logarithm of negative values is undefined"));
mp_set_from_integer(0, z);
return;
- }
+ }*/
if (mp_is_complex(x) || mp_is_negative(x)) {
MPNumber r, theta, z_real;
@@ -1627,11 +1638,12 @@ mp_pwr(const MPNumber *x, const MPNumber *y, MPNumber *z)
MPNumber t;
/* (-x)^y imaginary */
- if (x->sign < 0) {
+ /* FIXME: Make complex numbers optional */
+ /*if (x->sign < 0) {
mperr(_("The power of negative numbers is only defined for integer exponents"));
mp_set_from_integer(0, z);
return;
- }
+ }*/
/* 0^-y illegal */
if (mp_is_zero(x) && y->sign < 0) {
@@ -1731,7 +1743,7 @@ mp_reciprocal(const MPNumber *x, MPNumber *z)
void
-mp_root(const MPNumber *x, int64_t n, MPNumber *z)
+mp_root_real(const MPNumber *x, int64_t n, MPNumber *z)
{
float approximation;
int ex, np, it0, t;
@@ -1836,14 +1848,38 @@ mp_root(const MPNumber *x, int64_t n, MPNumber *z)
void
+mp_root(const MPNumber *x, int64_t n, MPNumber *z)
+{
+ if (!mp_is_complex(x) && mp_is_negative(x) && n % 2 == 1) {
+ mp_abs(x, z);
+ mp_root_real(z, n, z);
+ mp_invert_sign(z, z);
+ }
+ else if (mp_is_complex(x) || mp_is_negative(x)) {
+ MPNumber r, theta, i;
+
+ mp_abs(x, &r);
+ mp_arg(x, MP_RADIANS, &theta);
+
+ mp_root_real(&r, n, &r);
+ mp_divide_integer(&theta, n, &theta);
+ mp_set_from_polar(&r, MP_RADIANS, &theta, z);
+ }
+ else
+ mp_root_real(x, n, z);
+}
+
+
+void
mp_sqrt(const MPNumber *x, MPNumber *z)
{
if (mp_is_zero(x))
- mp_set_from_integer(0, z);
- else if (x->sign < 0) {
+ mp_set_from_integer(0, z);
+ /* FIXME: Make complex numbers optional */
+ /*else if (x->sign < 0) {
mperr(_("Square root is undefined for negative values"));
mp_set_from_integer(0, z);
- }
+ }*/
else {
MPNumber t;
diff --git a/src/unittest.c b/src/unittest.c
index 161b4af..ec2575b 100644
--- a/src/unittest.c
+++ b/src/unittest.c
@@ -378,7 +378,6 @@ test_equations()
test("4^3^2", "262144", 0);
test("4^(3^2)", "262144", 0);
test("(4^3)^2", "4096", 0);
- //test("e^(iÏ?)", "1", 0);
test("â??4", "2", 0);
test("â??4â??2", "0", 0);
test("â??8", "2", 0);
@@ -392,7 +391,7 @@ test_equations()
test("Sqrt(2)", "1.414213562", 0);
test("4^0.5", "2", 0);
test("2^0.5", "1.414213562", 0);
- test("(â??4)^0.5", "", PARSER_ERR_MP);
+ test("â??â??â??8", "â??2", 0);
test("(â??8)^(1÷3)", "â??2", 0);
test("0 mod 7", "0", 0);
@@ -435,7 +434,6 @@ test_equations()
test("abs 1", "1", 0);
test("abs (â??1)", "1", 0);
- test("log (â??1)", "", PARSER_ERR_MP);
test("log 0", "", PARSER_ERR_MP);
test("log 1", "0", 0);
test("log 2", "0.301029996", 0);
@@ -444,7 +442,6 @@ test_equations()
test("logâ?? 2", "1", 0);
test("2 log 2", "0.602059991", 0);
- test("ln (â??1)", "", PARSER_ERR_MP);
test("ln 0", "", PARSER_ERR_MP);
test("ln 1", "0", 0);
test("ln 2", "0.693147181", 0);
@@ -525,11 +522,18 @@ test_equations()
test("arg 1", "0", 0);
test("arg (1+i)", "45", 0);
test("arg i", "90", 0);
+ test("arg (â??1+i)", "135", 0);
test("arg â??1", "180", 0);
- test("arg â??i", "270", 0);
+ test("arg (1+â??i)", "â??45", 0);
+ test("arg â??i", "â??90", 0);
+ test("arg (â??1â??i)", "â??135", 0);
test("iâ?»Â¹", "â??i", 0);
- //test("â??â??1", "i", 0);
- //test("i^0.5", "i", 0);
+ test("â??â??1", "i", 0);
+ test("(â??1)^0.5", "i", 0);
+ test("â??â??4", "2i", 0);
+ test("e^iÏ?", "â??1", 0);
+ test("log (â??10) â?? (1 + Ï?i÷ln(10))", "0", 0);
+ test("ln (â??e) â?? (1 + Ï?i)", "0", 0);
/* Boolean */
test("0 and 0", "0", 0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]