[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [analitza/aucahuasi/matrixctrs] analitza/commands: Finish commands documentation.
From: Percy_Camilo_Triveño_Aucahuasi <percy.camilo.ta () gmail ! com>
Date: 2014-06-01 1:11:55
Message-ID: E1WquJX-0006PB-TZ () scm ! kde ! org
[Download RAW message or body]
Git commit 7242eaad7db21d1feb2322545c395e270504bc58 by Percy Camilo Triveño \
Aucahuasi. Committed on 01/06/2014 at 01:07.
Pushed by aucahuasi into branch 'aucahuasi/matrixctrs'.
Finish commands documentation.
M +3 -3 analitza/commands/blockmatrixcommands.h
M +1 -1 analitza/commands/listcommands.h
M +1 -0 analitza/commands/matrixcommands.cpp
M +64 -4 analitza/commands/matrixcommands.h
M +6 -61 analitza/commands/matrixqueries.cpp
M +3 -3 analitza/commands/matrixqueries.h
M +3 -4 analitza/commands/vectorcommands.h
http://commits.kde.org/analitza/7242eaad7db21d1feb2322545c395e270504bc58
diff --git a/analitza/commands/blockmatrixcommands.h \
b/analitza/commands/blockmatrixcommands.h index ad9a8e5..5b062b6 100644
--- a/analitza/commands/blockmatrixcommands.h
+++ b/analitza/commands/blockmatrixcommands.h
@@ -16,8 +16,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA \
*
*************************************************************************************/
-#ifndef MATRIXBUILTINMETHODS_H_3
-#define MATRIXBUILTINMETHODS_H_3
+#ifndef BLOCKMATRIXCOMMANDS_H
+#define BLOCKMATRIXCOMMANDS_H
#include "builtinmethods.h"
@@ -44,4 +44,4 @@ public:
};
-#endif // MATRIXBUILTINMETHODS_H
+#endif // BLOCKMATRIXCOMMANDS_H
diff --git a/analitza/commands/listcommands.h b/analitza/commands/listcommands.h
index bb7ad0a..6fb4d2e 100644
--- a/analitza/commands/listcommands.h
+++ b/analitza/commands/listcommands.h
@@ -31,7 +31,7 @@ class Expression;
* \brief Implements the \"range\" command.
*
* RangeCommand constructs a list that contains a sequence.
- * There are 3 ways to call this command:
+ * There are three ways to call this command:
*
* The first way creates a sequence from 1, with increment 1, that ends in
* the number \"b\".
diff --git a/analitza/commands/matrixcommands.cpp \
b/analitza/commands/matrixcommands.cpp index f8c61e5..bcc82c2 100644
--- a/analitza/commands/matrixcommands.cpp
+++ b/analitza/commands/matrixcommands.cpp
@@ -345,6 +345,7 @@ const ExpressionType TridiagonalMatrixCommand::type = \
ExpressionType(ExpressionT
.addParameter(ExpressionType(ExpressionType::Value))
.addParameter(ExpressionType(ExpressionType::Matrix, \
ExpressionType(ExpressionType::Vector, ExpressionType(ExpressionType::Value), -2), \
-1));
+//TODO create rectangular matrices too
Expression TridiagonalMatrixCommand::operator()(const QList< Analitza::Expression >& \
args) {
Expression ret;
diff --git a/analitza/commands/matrixcommands.h b/analitza/commands/matrixcommands.h
index c0f1e21..ba8905b 100644
--- a/analitza/commands/matrixcommands.h
+++ b/analitza/commands/matrixcommands.h
@@ -30,10 +30,9 @@ class Expression;
*
* \brief Implements the \"matrix\" command.
*
- * MatrixCommand constructs a matrix by 2 ways:
+ * MatrixCommand constructs a matrix by two ways:
*
* The first way creates a matrix filled with a fixed value.
- * For example:
* \code matrix(3) \endcode
* constructs a square 3x3 matrix filled with zeros.
*
@@ -44,7 +43,6 @@ class Expression;
* constructs a 6x7 matrix filled with the value 0.5.
*
* The second way creates a matrix by given vectors or matrixrow elements.
- * For example:
* \code matrix(vector{1,3}, vector{4,5}) \endcode
* constructs a matrix with two column vectors:
* [1 4]
@@ -87,6 +85,56 @@ public:
static const Analitza::ExpressionType type;
};
+/**
+ * \class DiagonalMatrixCommand
+ *
+ * \brief Implements the \"diag\" command.
+ *
+ * DiagonalMatrixCommand can be used to construct a diagonal matrix and also
+ * to get the diagonal part of a matrix.
+ *
+ * There are two ways to construct a diagonal matrix:
+ *
+ * The first way creates the diagonal part out of the paramaters.
+ * \code diag(1,2,3) \endcode
+ * constructs the 3x3 diagonal matrix:
+ * [1 0 0]
+ * [0 2 0]
+ * [0 0 3]
+ *
+ * The second way uses a vector as the diagonal part:
+ * \code diag(vector{1,2,3}) \endcode
+ * is equivalent to
+ * \code diag(1,2,3) \endcode
+ *
+ * There are two ways to get the diagonal part of a matrix, also both always
+ * return a vector that contains the requested diagonal part.
+ *
+ * The first way always get the principal diagonal of the a given matrix.
+ * \code diag(matrix{matrixrow{1,2}, matrixrow{3,4}}) \endcode
+ * returns
+ * \code vector{1,4} \endcode
+ *
+ * The second way returns a vector of the elements on the nth diagonal of
+ * a given matrix.
+ *
+ * k>0 is above the main diagonal
+ * k<0 is below the main
+ *
+ * \code diag(matrix{matrixrow{1,2}, matrixrow{3,4}}, 0) \endcode
+ * is equivalent to
+ * \code diag(matrix{matrixrow{1,2}, matrixrow{3,4}}) \endcode
+ *
+ * \code diag(matrix{matrixrow{1,2}, matrixrow{3,4}}, 1) \endcode
+ * returns
+ * \code vector{2} \endcode
+ *
+ * \code diag(matrix{matrixrow{1,2}, matrixrow{3,4}}, -1) \endcode
+ * returns
+ * \code vector{3} \endcode
+ *
+ */
+
class DiagonalMatrixCommand: public Analitza::FunctionDefinition
{
public:
@@ -96,7 +144,19 @@ public:
static const Analitza::ExpressionType type;
};
-//tridiag(a, b, c, n)
+/**
+ * \class TridiagonalMatrixCommand
+ *
+ * \brief Implements the \"tridiag\" command.
+ *
+ * TridiagonalMatrixCommand constructs a tridiagonal matrix.
+ *
+ * \code tridiag(a, b, c, n) \endcode
+ * where b is in the main diagonal, a is below the main diagonal,
+ * c is above the main diagonal and n is the size of the matrix.
+ *
+ */
+
class TridiagonalMatrixCommand: public Analitza::FunctionDefinition
{
public:
diff --git a/analitza/commands/matrixqueries.cpp \
b/analitza/commands/matrixqueries.cpp index 48a8af3..4e803e8 100644
--- a/analitza/commands/matrixqueries.cpp
+++ b/analitza/commands/matrixqueries.cpp
@@ -24,68 +24,20 @@
#include "expression.h"
#include "value.h"
#include "matrix.h"
-#include "list.h"
-#include "container.h"
-#include "operations.h"
using Analitza::Expression;
using Analitza::ExpressionType;
-//BEGIN type utils
-
-typedef QList<ExpressionType> ExpressionTypeList;
-
-static const ExpressionType ValueType = ExpressionType(ExpressionType::Value);
-static const ExpressionType VectorType = ExpressionType(ExpressionType::Vector, \
ExpressionType(ExpressionType::Value), -1);
-static const ExpressionType MatrixType = ExpressionType(ExpressionType::Matrix, \
ExpressionType(ExpressionType::Vector, ExpressionType(ExpressionType::Value), -2), \
-1);
-static const ExpressionTypeList VectorAndMatrixTypes = ExpressionTypeList() << \
VectorType << MatrixType;
-static const ExpressionType VectorAndMatrixAlternatives = \
ExpressionType(ExpressionType::Many, VectorAndMatrixTypes);
-static const ExpressionType IndefiniteArityType = \
ExpressionType(ExpressionType::Any);
-
-static const ExpressionType functionType(const ExpressionTypeList &from, const \
ExpressionType &to)
-{
- ExpressionType ret(ExpressionType::Lambda);
-
- foreach (const ExpressionType &type, from)
- ret.addParameter(type);
-
- ret.addParameter(to);
-
- return ret;
-}
-
-static const ExpressionType functionType(const ExpressionType &from, const \
ExpressionType &to)
-{
- return functionType(ExpressionTypeList() << from, to);
-}
-
-static const ExpressionType variadicFunctionType(const ExpressionType &to)
-{
- return functionType(IndefiniteArityType, to);
-}
-
-//END type utils
-
-static const QString MATRIX_SIZE_ERROR_MESSAGE = QCoreApplication::tr("Matrix \
dimensions must be greater than zero");
-
-// const QString VectorCommand::id = QString("range");
-// // const ExpressionType VectorCommand::type = functionType(ExpressionTypeList() \
<< ValueType << ValueType, VectorType);
-//
-// Expression RangeCommand::operator()(const QList< Analitza::Expression >& args)
-// {
-//
-// }
-
-
-
//BEGIN IsZeroMatrix
const QString IsZeroMatrixCommand::id = QString("iszeromatrix");
-const ExpressionType IsZeroMatrixCommand::type = functionType(MatrixType, \
ValueType); +const ExpressionType IsZeroMatrixCommand::type = \
ExpressionType(ExpressionType::Lambda) \
+.addParameter(ExpressionType(ExpressionType::Matrix, \
ExpressionType(ExpressionType::Vector, ExpressionType(ExpressionType::Value), -2), \
-1)) +.addParameter(ExpressionType(ExpressionType::Value));
Expression IsZeroMatrixCommand::operator()(const QList< Analitza::Expression >& \
args) {
- qDebug() << "bam bam " << args.first().toString(); //TODO last test
+// qDebug() << "bam bam " << args.first().toString(); //TODO last test
return Expression(new Analitza::Cn(static_cast<const \
Analitza::Matrix*>(args.first().tree())->isZero())); }
@@ -93,7 +45,7 @@ Expression IsZeroMatrixCommand::operator()(const QList< \
Analitza::Expression >&
const QString IsIdentityMatrixCommand::id = QString("isidentitymatrix");
-const ExpressionType IsIdentityMatrixCommand::type = functionType(MatrixType, \
ValueType); +const ExpressionType IsIdentityMatrixCommand::type = \
IsZeroMatrixCommand::type;
Expression IsIdentityMatrixCommand::operator()(const QList< Analitza::Expression >& \
args) {
@@ -101,16 +53,9 @@ Expression IsIdentityMatrixCommand::operator()(const QList< \
Analitza::Expression }
const QString IsDiagonalMatrixCommand::id = QString("isdiag");
-const ExpressionType IsDiagonalMatrixCommand::type = \
variadicFunctionType(VectorType); +const ExpressionType IsDiagonalMatrixCommand::type \
= IsZeroMatrixCommand::type;
Expression IsDiagonalMatrixCommand::operator()(const QList< Analitza::Expression >& \
args) {
- if (args.size() != 1) {
- Expression ret;
- ret.addError(QCoreApplication::tr("Invalid parameter count for '%2'. Should have \
%1 parameters.").arg(1).arg(IsDiagonalMatrixCommand::id));
-
- return ret;
- }
-
return Expression(new \
Analitza::Cn(AnalitzaUtils::isIdentityMatrix(static_cast<const \
Analitza::Matrix*>(args.first().tree())))); }
diff --git a/analitza/commands/matrixqueries.h b/analitza/commands/matrixqueries.h
index 1b0c5f3..628b634 100644
--- a/analitza/commands/matrixqueries.h
+++ b/analitza/commands/matrixqueries.h
@@ -16,8 +16,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA \
*
*************************************************************************************/
-#ifndef MATRIXBUILTINMETHODS_H_2
-#define MATRIXBUILTINMETHODS_H_2
+#ifndef MATRIXQUERIES_H
+#define MATRIXQUERIES_H
#include "builtinmethods.h"
@@ -52,4 +52,4 @@ public:
static const Analitza::ExpressionType type;
};
-#endif // MATRIXBUILTINMETHODS_H
+#endif // MATRIXQUERIES_H
diff --git a/analitza/commands/vectorcommands.h b/analitza/commands/vectorcommands.h
index 5845428..2fa1663 100644
--- a/analitza/commands/vectorcommands.h
+++ b/analitza/commands/vectorcommands.h
@@ -31,15 +31,14 @@ class Expression;
*
* \brief Implements the \"vector\" command.
*
- * VectorCommand constructs a vector by 2 ways:
+ * VectorCommand constructs a vector by two ways:
*
- * The first way creates a vector from a list, with the same list elements.
- * For example:
+ * The first way creates a vector from a list, with the same list elements.
* \code vector(range(5)) \endcode
* constructs
* \code vector { 1, 2, 3, 4, 5 } \endcode
*
- * The second way creates a vector of size \"n\" filled with a value \"a\".
+ * The second way creates a vector of size \"n\" filled with a value \"a\":
* \code vector(n, a) \endcode
* constructs
* \code vector { a, a, ... , a } \endcode
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic