[genius] Sun Dec 23 13:22:07 2012 Jiri (George) Lebl <jirka 5z com>
- From: George Lebl <jirka src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [genius] Sun Dec 23 13:22:07 2012 Jiri (George) Lebl <jirka 5z com>
- Date: Sun, 23 Dec 2012 19:23:37 +0000 (UTC)
commit aab6b7039a367d8501f37fd6ede51ba909bd7a1c
Author: Jiri (George) Lebl <jirka 5z com>
Date: Sun Dec 23 13:22:11 2012 -0600
Sun Dec 23 13:22:07 2012 Jiri (George) Lebl <jirka 5z com>
* help/C/genius.xml: fix documentation of less than and greater than
(thanks to Marek Cernocky). Also expand the documentation in
several places a little.
ChangeLog | 6 +++++
help/C/genius.xml | 34 +++++++++++++++++++++---------
help/genius.txt | 58 +++++++++++++++++++++++++++++++++++-----------------
3 files changed, 69 insertions(+), 29 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index ea8c255..3abde46 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Sun Dec 23 13:22:07 2012 Jiri (George) Lebl <jirka 5z com>
+
+ * help/C/genius.xml: fix documentation of less than and greater than
+ (thanks to Marek Cernocky). Also expand the documentation in
+ several places a little.
+
Tue Dec 18 20:49:50 2012 Jiri (George) Lebl <jirka 5z com>
* src/mpwrap.c, src/calc.c: make a minor optimization, and remove an
diff --git a/help/C/genius.xml b/help/C/genius.xml
index 38bec0c..75e4596 100644
--- a/help/C/genius.xml
+++ b/help/C/genius.xml
@@ -1110,11 +1110,13 @@ To use it you just add "mod <integer>" after
the expression. Example:
<programlisting>2^(5!) * 3^(6!) mod 5</programlisting>
It could be possible to do modular arithmetic by computing with integers and then modding in the end with
-the <literal>%</literal> operator, but
+the <literal>%</literal> operator, which simply gives the remainder, but
that may be time consuming if not impossible when working with larger numbers.
-For example <userinput>10^(10^10) % 6</userinput> will simply not work (the exponent
+For example, <userinput>10^(10^10) % 6</userinput> will simply not work (the exponent
will be too large), while
-<userinput>10^(10^10) mod 6</userinput> is instanteneous.
+<userinput>10^(10^10) mod 6</userinput> is instanteneous. The first expression first tries to compute the integer
+<userinput>10^(10^10)</userinput> and then find remainder after division by 6, while the second expression evaluates
+everything modulo 6 to begin with.
</para>
<para>
You can calculate the inverses of numbers mod some integer by just using
@@ -1145,6 +1147,16 @@ genius> 2*2 mod 7
<function>sqrt</function> will actually return all the possible square
roots.
</para>
+ <para>
+ Do not chain mod operators, simply place it at the end of the computation, all computations in the expression on the left
+ will be carried out in mod arithmetic. If you place a mod inside
+ a mod, you will get unexpected results. If you simply want to
+ mod a single number and control exactly when remainders are
+ taken, best to use the <literal>%</literal> operator. When you
+ need to chain several expressions in modular arithmetic with
+ different divisors, it may be best to just split up the expression into several and use
+ temporary variables to avoid a mod inside a mod.
+ </para>
</sect1>
<sect1 id="genius-gel-operator-list">
@@ -1456,7 +1468,7 @@ different from <literal>=</literal> because it never gets translated to a
<para>
Less than operator,
returns <constant>true</constant> if <varname>a</varname> is
- less than or equal to
+ less than
<varname>b</varname> else returns <constant>false</constant>.
These can be chained as in <userinput>a < b < c</userinput>
(can also be combine with the less than or equal to operator).
@@ -1471,7 +1483,7 @@ different from <literal>=</literal> because it never gets translated to a
<para>
Greater than operator,
returns <constant>true</constant> if <varname>a</varname> is
- greater than or equal to
+ greater than
<varname>b</varname> else returns <constant>false</constant>.
These can be chained as in <userinput>a > b > c</userinput>
(can also be combine with the greater than or equal to operator).
@@ -1549,7 +1561,7 @@ different from <literal>=</literal> because it never gets translated to a
<term><synopsis>-a</synopsis></term>
<listitem>
<para>
- Negation operator.
+ Negation operator. Returns the negative of a number or a matrix (works elementwise on a matrix).
</para>
</listitem>
</varlistentry>
@@ -1559,7 +1571,7 @@ different from <literal>=</literal> because it never gets translated to a
<term><synopsis>&a</synopsis></term>
<listitem>
<para>
- Variable referencing (to pass a reference to something).
+ Variable referencing (to pass a reference to a variable).
See <xref linkend='genius-gel-references' />.
</para>
</listitem>
@@ -1581,7 +1593,8 @@ different from <literal>=</literal> because it never gets translated to a
<term><synopsis>a'</synopsis></term>
<listitem>
<para>
- Matrix conjugate transpose.
+ Matrix conjugate transpose. That is, rows and columns get swapped and we take complex conjugate of all entries. That is
+ if the i,j element of <varname>a</varname> is x+iy, then the j,i element of <userinput>a'</userinput> is x-iy.
</para>
</listitem>
</varlistentry>
@@ -1591,7 +1604,8 @@ different from <literal>=</literal> because it never gets translated to a
<term><synopsis>a.'</synopsis></term>
<listitem>
<para>
- Matrix transpose, does not conjugate the entries.
+ Matrix transpose, does not conjugate the entries. That is, the
+ the i,j element of <varname>a</varname> becomes the j,i element of <userinput>a.'</userinput>.
</para>
</listitem>
</varlistentry>
@@ -1614,7 +1628,7 @@ different from <literal>=</literal> because it never gets translated to a
<term><synopsis>a@(b,)</synopsis></term>
<listitem>
<para>
- Get row of a matrix (or rows if <varname>b</varname> is a vector).
+ Get row of a matrix (or multiple rows if <varname>b</varname> is a vector).
</para>
</listitem>
</varlistentry>
diff --git a/help/genius.txt b/help/genius.txt
index c3231f1..282e4fc 100644
--- a/help/genius.txt
+++ b/help/genius.txt
@@ -951,11 +951,14 @@ Modular Evaluation
2^(5!) * 3^(6!) mod 5
It could be possible to do modular arithmetic by computing with
- integers and then modding in the end with the % operator, but
- that may be time consuming if not impossible when working with
- larger numbers. For example 10^(10^10) % 6 will simply not work
- (the exponent will be too large), while 10^(10^10) mod 6 is
- instanteneous.
+ integers and then modding in the end with the % operator, which
+ simply gives the remainder, but that may be time consuming if
+ not impossible when working with larger numbers. For example,
+ 10^(10^10) % 6 will simply not work (the exponent will be too
+ large), while 10^(10^10) mod 6 is instanteneous. The first
+ expression first tries to compute the integer 10^(10^10) and
+ then find remainder after division by 6, while the second
+ expression evaluates everything modulo 6 to begin with.
You can calculate the inverses of numbers mod some integer by
just using rational numbers (of course the inverse has to
@@ -983,6 +986,17 @@ genius> 2*2 mod 7
= 4
sqrt will actually return all the possible square roots.
+
+ Do not chain mod operators, simply place it at the end of the
+ computation, all computations in the expression on the left
+ will be carried out in mod arithmetic. If you place a mod
+ inside a mod, you will get unexpected results. If you simply
+ want to mod a single number and control exactly when remainders
+ are taken, best to use the % operator. When you need to chain
+ several expressions in modular arithmetic with different
+ divisors, it may be best to just split up the expression into
+ several and use temporary variables to avoid a mod inside a
+ mod.
__________________________________________________________
List of GEL Operators
@@ -1128,17 +1142,17 @@ a>=b
a<b
- Less than operator, returns true if a is less than or
- equal to b else returns false. These can be chained as
- in a < b < c (can also be combine with the less than or
- equal to operator).
+ Less than operator, returns true if a is less than b
+ else returns false. These can be chained as in a < b < c
+ (can also be combine with the less than or equal to
+ operator).
a>b
Greater than operator, returns true if a is greater than
- or equal to b else returns false. These can be chained
- as in a > b > c (can also be combine with the greater
- than or equal to operator).
+ b else returns false. These can be chained as in a > b >
+ c (can also be combine with the greater than or equal to
+ operator).
a<=>b
@@ -1170,13 +1184,14 @@ not a
-a
- Negation operator.
+ Negation operator. Returns the negative of a number or a
+ matrix (works elementwise on a matrix).
&a
- Variable referencing (to pass a reference to something).
- See the Section called References in the Chapter called
- Programming with GEL.
+ Variable referencing (to pass a reference to a
+ variable). See the Section called References in the
+ Chapter called Programming with GEL.
*a
@@ -1186,11 +1201,16 @@ not a
a'
- Matrix conjugate transpose.
+ Matrix conjugate transpose. That is, rows and columns
+ get swapped and we take complex conjugate of all
+ entries. That is if the i,j element of a is x+iy, then
+ the j,i element of a' is x-iy.
a.'
- Matrix transpose, does not conjugate the entries.
+ Matrix transpose, does not conjugate the entries. That
+ is, the the i,j element of a becomes the j,i element of
+ a.'.
a@(b,c)
@@ -1200,7 +1220,7 @@ a@(b,c)
a@(b,)
- Get row of a matrix (or rows if b is a vector).
+ Get row of a matrix (or multiple rows if b is a vector).
a@(b,:)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]