summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Braun <syn@sceen.net>2006-05-30 17:05:53 +0000
committerRichard Braun <syn@sceen.net>2006-05-30 17:05:53 +0000
commitfaddfc52f7e364cfddb4da26308e9d75e9011904 (patch)
treead07258fffacd5a1d8ddc8ce4fb5e6c2ad3cc427
parent2ab48b799578c6bfaa60d2703e874918e3e3005a (diff)
Fixed documentation.
-rw-r--r--Makefile2
-rw-r--r--mtx.h128
2 files changed, 128 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 37d62bf..1235a0d 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
# $Id$
CC = g++
-CPPFLAGS = -g -Wall $$(pkg-config gtkmm-2.0 --cflags) # -D USE_64BITS_WORDS
+CPPFLAGS = -Wall $$(pkg-config gtkmm-2.0 --cflags) # -D USE_64BITS_WORDS
LIBS =
HEADERS = mtx.h mtxinteger.h mtxrational.h mtxmatrix.h mtxexception.h \
mtxdivbyzeroexception.h mtxsingularmatrixexception.h \
diff --git a/mtx.h b/mtx.h
index 57ce4cd..254b40b 100644
--- a/mtx.h
+++ b/mtx.h
@@ -47,6 +47,7 @@
* mtx_cli> ans
* ans = 5
* </pre>
+ *
* An immediate value is considered to be an integer or, if a dot
* (".") is found, a rational :
* <pre>
@@ -55,11 +56,136 @@
* mtx_cli> 1.23
* ans = 123/100
* </pre>
- * Assignment uses the <code>=</code> operator :
+ *
+ * As you can see, <i>ans</i> is an automatic variable which is set when
+ * the result of an expression is unnamed.
+ *
+ * Assignment is done with the <code>=</code> operator :
* <pre>
* mtx_cli> a=123
* a = 123
* </pre>
+ *
+ * When assigning a value, the left value must be an <i>lvalue</i>, which means
+ * it must be a named variable, or refer to it. For example,
+ * <code>(a = 1) = 2</code> sets a to 2, because the expression
+ * (a = 1) returns a.
+ *
+ * \subsection usage_operator Operators
+ *
+ * Here is the list of supported operators :
+ * - = : assign the value of the right expression to the lvalue of the left
+ * expression
+ * - +=, -=, *=, /= : execute the operator on the left and right expressions,
+ * and assign the result to the lvalue of the left
+ * expression
+ * - + - : (unary operators) return the value of the expression (+) or its
+ * opposite (-).
+ * - + - * / : (binary operators) execute the operator on the right and
+ * left expressions and return teh result as a temporary
+ * (unnamed) variable.
+ * - () : force execution of the inner expression before evaluating
+ * the global expression
+ * - f() : use function f
+ * - [] : create a matrix
+ * - , ; : separate expressions (when not used as a separator of function
+ * arguments or matrix elements - ; makes the expressions silent)
+ *
+ * \subsection usage_matrices Matrices
+ *
+ * A matrix is created using the [] operator. The ; character separates lines
+ * whereas the , character separates columns. For example :
+ * <pre>
+ * mtx_cli> matrix = [1,2,3;4,5,6;7,8,9]
+ * matrix =
+ *
+ * 1 2 3
+ * 4 5 6
+ * 7 8 9
+ *
+ * </pre>
+ *
+ * \subsection usage_functions Functions
+ *
+ * A small set of builtin functions can be used on matrices. These are :
+ *
+ * det : compute the determinant of a matrix
+ * <pre>
+ * mtx_cli> det([1,2;3,4])
+ * ans = -2
+ * </pre>
+ *
+ * inverse : compute the inverse of a matrix
+ * <pre>
+ * mtx_cli> inverse([1,2;3,4])
+ * ans =
+ *
+ * -2 1
+ * 3/2 -1/2
+ *
+ * </pre>
+ *
+ * transpose : compute the transpose of a matrix
+ * <pre>
+ * mtx_cli> transpose([1,2;3,4])
+ * ans =
+ *
+ * 1 3
+ * 2 4
+ *
+ * </pre>
+ *
+ * augment : compute the augmented matrix of two matrices
+ * <pre>
+ * mtx_cli> matrix1=[1,2;3,4];matrix2=[5,6;7,8];
+ * mtx_cli> augment(matrix1, matrix2)
+ * ans =
+ *
+ * 1 2 5 6
+ * 3 4 7 8
+ *
+ * </pre>
+ *
+ * lu : compute the LU decomposition of a matrix
+ * <pre>
+ * mtx_cli> lu([1,2;3,4], l, u)
+ * ans = 1
+ * mtx_cli> l,u
+ * l =
+ *
+ * 1 0
+ * 3 1
+ *
+ * u =
+ *
+ * 1 2
+ * 0 -2
+ *
+ * </pre>
+ *
+ * \subsection usage_inputfile Input file
+ *
+ * When using the CLI interface, you can use a file which contains expressions
+ * on each line :
+ * <pre>
+ * $ ./mtx_cli test.mtx
+ * mtx 0.1
+ * Copyright (C) 2005-2006 Richard Braun.
+ * This is free software. You may redistribute copies of it under the terms of
+ * the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
+ * There is NO WARRANTY, to the extent permitted by law.
+ *
+ * mtx_cli> matrix1=[1,2;3,4];matrix2=[5,6;7,8];
+ * mtx_cli> augment(matrix1, matrix2)
+ * ans =
+ *
+ * 1 2 5 6
+ * 3 4 7 8
+ *
+ * $
+ * </pre>
+ *
+ * Have fun using mtx.
*/
/**