File indexing completed on 2024-05-26 11:22:03

0001 /*
0002     SPDX-License-Identifier: GPL-2.0-or-later
0003     SPDX-FileCopyrightText: 2016 Ivan Lakhtanov <ivan.lakhtanov@gmail.com>
0004 */
0005 #pragma once
0006 
0007 #include <extension.h>
0008 
0009 #define JULIA_EXT_CDTOR_DECL(name) Julia##name##Extension(QObject *parent); \
0010                                    ~Julia##name##Extension();
0011 
0012 
0013 /**
0014  * Implementation of linear algebra wizards for Julia
0015  */
0016 class JuliaLinearAlgebraExtension: public Cantor::LinearAlgebraExtension
0017 {
0018 public:
0019     JULIA_EXT_CDTOR_DECL(LinearAlgebra)
0020 
0021     /**
0022      * @see Cantor::LinearAlgebraExtension::createVector
0023      */
0024     QString createVector(
0025         const QStringList &entries,
0026         VectorType type) override;
0027 
0028     /**
0029      * @see Cantor::LinearAlgebraExtension::nullVector
0030      */
0031     QString nullVector(int size, VectorType type) override;
0032 
0033     /**
0034      * @see Cantor::LinearAlgebraExtension::createMatrix
0035      */
0036     QString createMatrix(
0037         const Cantor::LinearAlgebraExtension::Matrix &matrix) override;
0038 
0039     /**
0040      * @see Cantor::LinearAlgebraExtension::identityMatrix
0041      */
0042     QString identityMatrix(int size) override;
0043 
0044     /**
0045      * @see Cantor::LinearAlgebraExtension::nullMatrix
0046      */
0047     QString nullMatrix(int rows, int columns) override;
0048 
0049     /**
0050      * @see Cantor::LinearAlgebraExtension::rank
0051      */
0052     QString rank(const QString &matrix) override;
0053 
0054     /**
0055      * @see Cantor::LinearAlgebraExtension::invertMatrix
0056      */
0057     QString invertMatrix(const QString &matrix) override;
0058 
0059     /**
0060      * @see Cantor::LinearAlgebraExtension::charPoly
0061      */
0062     QString charPoly(const QString &matrix) override;
0063 
0064     /**
0065      * @see Cantor::LinearAlgebraExtension::eigenVectors
0066      */
0067     QString eigenVectors(const QString &matrix) override;
0068 
0069     /**
0070      * @see Cantor::LinearAlgebraExtension::eigenValues
0071      */
0072     QString eigenValues(const QString &matrix) override;
0073 };
0074 
0075 /**
0076  * Implementation of packaging wizards for Julia
0077  */
0078 class JuliaPackagingExtension: public Cantor::PackagingExtension
0079 {
0080 public:
0081     JULIA_EXT_CDTOR_DECL(Packaging)
0082 
0083     /**
0084      * @see Cantor::PackagingExtension::importPackage
0085      */
0086     QString importPackage(const QString &module) override;
0087 };
0088 
0089 /**
0090  * Implementation of plot wizards for Julia
0091  *
0092  * Plotting is based on GR package
0093  */
0094 class JuliaPlotExtension: public Cantor::PlotExtension
0095 {
0096 public:
0097     JULIA_EXT_CDTOR_DECL(Plot)
0098 
0099     /**
0100      * @see Cantor::PlotExtension::plotFunction2d
0101      */
0102     QString plotFunction2d(
0103         const QString &function,
0104         const QString &variable,
0105         const QString &left,
0106         const QString &right) override;
0107 
0108     /**
0109      * @see Cantor::PlotExtension::plotFunction3d
0110      */
0111     QString plotFunction3d(
0112         const QString &function,
0113         const VariableParameter& var1,
0114         const VariableParameter& var2) override;
0115 };
0116 
0117 /**
0118  * Implementation of script wizard for Julia
0119  */
0120 class JuliaScriptExtension: public Cantor::ScriptExtension
0121 {
0122 public:
0123     JULIA_EXT_CDTOR_DECL(Script)
0124 
0125     /**
0126      * @see Cantor::ScriptExtension::scriptFileFilter
0127      */
0128     QString scriptFileFilter() override;
0129 
0130     /**
0131      * @see Cantor::ScriptExtension::highlightingMode
0132      */
0133     QString highlightingMode() override;
0134 
0135     /**
0136      * @see Cantor::ScriptExtension::runExternalScript
0137      */
0138     QString runExternalScript(const QString &path) override;
0139 };
0140 
0141 /**
0142  * Julia variable management extension
0143  *
0144  * Based on JLD package for loading/saving variables
0145  */
0146 class JuliaVariableManagementExtension: public Cantor::VariableManagementExtension
0147 {
0148 public:
0149     JULIA_EXT_CDTOR_DECL(VariableManagement)
0150 
0151     // There is no way to completely delete object from scope:
0152     // https://docs.julialang.org/en/v1/manual/faq/#How-do-I-delete-an-object-in-memory?-1
0153     // So we are saving special marker to variable to mark it as removed
0154     static const QString REMOVED_VARIABLE_MARKER;
0155 
0156     /**
0157      * @see Cantor::VariableManagementExtension::addVariable
0158      */
0159     QString addVariable(
0160         const QString &name,
0161         const QString &value) override;
0162 
0163     /**
0164      * @see Cantor::VariableManagementExtension::setValue
0165      */
0166     QString setValue(
0167         const QString &name,
0168         const QString &value) override;
0169 
0170     /**
0171      * @see Cantor::VariableManagementExtension::removeVariable
0172      */
0173     QString removeVariable(const QString &name) override;
0174 
0175     /**
0176      * @see Cantor::VariableManagementExtension::saveVariables
0177      */
0178     QString saveVariables(const QString &fileName) override;
0179 
0180     /**
0181      * @see Cantor::VariableManagementExtension::loadVariables
0182      */
0183     QString loadVariables(const QString &fileName) override;
0184 
0185     /**
0186      * @see Cantor::VariableManagementExtension::clearVariables
0187      */
0188     QString clearVariables() override;
0189 };