File indexing completed on 2024-05-12 03:41:58

0001 /*************************************************************************************
0002  *  Copyright (C) 2014 by Percy Camilo T. Aucahuasi <percy.camilo.ta@gmail.com>      *
0003  *                                                                                   *
0004  *  This program is free software; you can redistribute it and/or                    *
0005  *  modify it under the terms of the GNU General Public License                      *
0006  *  as published by the Free Software Foundation; either version 2                   *
0007  *  of the License, or (at your option) any later version.                           *
0008  *                                                                                   *
0009  *  This program is distributed in the hope that it will be useful,                  *
0010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of                   *
0011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                    *
0012  *  GNU General Public License for more details.                                     *
0013  *                                                                                   *
0014  *  You should have received a copy of the GNU General Public License                *
0015  *  along with this program; if not, write to the Free Software                      *
0016  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA   *
0017  *************************************************************************************/
0018 
0019 #include "matrixqueries.h"
0020 
0021 #include <QCoreApplication>
0022 
0023 #include "expression.h"
0024 #include "value.h"
0025 #include "matrix.h"
0026 
0027 using Analitza::Expression;
0028 using Analitza::ExpressionType;
0029 
0030 //BEGIN IsZeroMatrix
0031 
0032 const QString IsZeroMatrixCommand::id = QStringLiteral("iszeromatrix");
0033 const ExpressionType IsZeroMatrixCommand::type = ExpressionType(ExpressionType::Lambda)
0034 .addParameter(ExpressionType(ExpressionType::Matrix, ExpressionType(ExpressionType::Vector, ExpressionType(ExpressionType::Value), -2), -1))
0035 .addParameter(ExpressionType(ExpressionType::Value));
0036 
0037 Expression IsZeroMatrixCommand::operator()(const QList< Analitza::Expression >& args)
0038 {
0039     return Expression(new Analitza::Cn(static_cast<const Analitza::Matrix*>(args.first().tree())->isZero()));
0040 }
0041 
0042 //END IsZeroMatrix
0043 
0044 const QString IsIdentityMatrixCommand::id = QStringLiteral("isidentitymatrix");
0045 const ExpressionType IsIdentityMatrixCommand::type = IsZeroMatrixCommand::type;
0046 
0047 Expression IsIdentityMatrixCommand::operator()(const QList< Analitza::Expression >& args)
0048 {
0049     return Expression(new Analitza::Cn(static_cast<const Analitza::Matrix*>(args.first().tree())->isIdentity()));
0050 }
0051 
0052 const QString IsDiagonalMatrixCommand::id = QStringLiteral("isdiag");
0053 const ExpressionType IsDiagonalMatrixCommand::type = IsZeroMatrixCommand::type;
0054 
0055 Expression IsDiagonalMatrixCommand::operator()(const QList< Analitza::Expression >& args)
0056 {
0057     return Expression(new Analitza::Cn(static_cast<const Analitza::Matrix*>(args.first().tree())->isDiagonal()));
0058 }