commit dec5fa0fa1a742db4b7504048abd66939f48dbda Author: moerp Date: Sat May 22 22:43:44 2021 +0200 Initial commit diff --git a/SQM-GUI-ng.pro b/SQM-GUI-ng.pro new file mode 100644 index 0000000..5917a10 --- /dev/null +++ b/SQM-GUI-ng.pro @@ -0,0 +1,26 @@ +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +CONFIG += c++11 + +# You can make your code fail to compile if it uses deprecated APIs. +# In order to do so, uncomment the following line. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +SOURCES += \ + main.cpp \ + mainwindow.cpp \ + sqmtablemodel.cpp + +HEADERS += \ + mainwindow.h \ + sqmtablemodel.h + +FORMS += \ + mainwindow.ui + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target diff --git a/SQM-GUI-ng.pro.user b/SQM-GUI-ng.pro.user new file mode 100644 index 0000000..8153fb9 --- /dev/null +++ b/SQM-GUI-ng.pro.user @@ -0,0 +1,322 @@ + + + + + + EnvironmentId + {500a65f7-9d99-4e4c-94ca-f6a1a717d58b} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + false + true + false + 0 + true + true + 0 + 8 + true + false + 1 + true + true + true + *.md, *.MD, Makefile + false + true + + + + ProjectExplorer.Project.PluginSettings + + + true + false + true + true + true + true + + + 0 + true + + -fno-delayed-template-parsing + + true + Builtin.BuildSystem + + true + true + Builtin.DefaultTidyAndClazy + 8 + + + + true + + + + + ProjectExplorer.Project.Target.0 + + Desktop + Desktop Qt 6.1.0 MinGW 64-bit + Desktop Qt 6.1.0 MinGW 64-bit + qt.qt6.610.win64_mingw81_kit + 0 + 0 + 0 + + 0 + C:\Users\matth\Documents\build-SQM-GUI-ng-Desktop_Qt_6_1_0_MinGW_64_bit-Debug + C:/Users/matth/Documents/build-SQM-GUI-ng-Desktop_Qt_6_1_0_MinGW_64_bit-Debug + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Erstellen + Erstellen + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Bereinigen + Bereinigen + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + + + C:\Users\matth\Documents\build-SQM-GUI-ng-Desktop_Qt_6_1_0_MinGW_64_bit-Release + C:/Users/matth/Documents/build-SQM-GUI-ng-Desktop_Qt_6_1_0_MinGW_64_bit-Release + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Erstellen + Erstellen + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Bereinigen + Bereinigen + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + + + 0 + C:\Users\matth\Documents\build-SQM-GUI-ng-Desktop_Qt_6_1_0_MinGW_64_bit-Profile + C:/Users/matth/Documents/build-SQM-GUI-ng-Desktop_Qt_6_1_0_MinGW_64_bit-Profile + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Erstellen + Erstellen + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Bereinigen + Bereinigen + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Profile + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + 0 + + 3 + + + 0 + Deployment + Deployment + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + 1 + + dwarf + + cpu-cycles + + + 250 + + -e + cpu-cycles + --call-graph + dwarf,4096 + -F + 250 + + -F + true + 4096 + false + false + 1000 + + true + + + false + false + false + false + true + 0.01 + 10 + true + kcachegrind + 1 + + 25 + + 1 + true + false + true + + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + + 2 + + SQM-GUI-ng2 + Qt4ProjectManager.Qt4RunConfiguration:C:/Users/matth/Documents/Workspace/MPI/SQM-GUI-ng/SQM-GUI-ng.pro + C:/Users/matth/Documents/Workspace/MPI/SQM-GUI-ng/SQM-GUI-ng.pro + false + true + true + false + true + C:/Users/matth/Documents/build-SQM-GUI-ng-Desktop_Qt_6_1_0_MinGW_64_bit-Debug + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 22 + + + Version + 22 + + diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..fd3e533 --- /dev/null +++ b/main.cpp @@ -0,0 +1,11 @@ +#include "mainwindow.h" + +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MainWindow w; + w.show(); + return a.exec(); +} diff --git a/mainwindow.cpp b/mainwindow.cpp new file mode 100644 index 0000000..41a26bd --- /dev/null +++ b/mainwindow.cpp @@ -0,0 +1,15 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" + +MainWindow::MainWindow(QWidget *parent) + : QMainWindow(parent) + , ui(new Ui::MainWindow) +{ + ui->setupUi(this); +} + +MainWindow::~MainWindow() +{ + delete ui; +} + diff --git a/mainwindow.h b/mainwindow.h new file mode 100644 index 0000000..4643e32 --- /dev/null +++ b/mainwindow.h @@ -0,0 +1,21 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include + +QT_BEGIN_NAMESPACE +namespace Ui { class MainWindow; } +QT_END_NAMESPACE + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + MainWindow(QWidget *parent = nullptr); + ~MainWindow(); + +private: + Ui::MainWindow *ui; +}; +#endif // MAINWINDOW_H diff --git a/mainwindow.ui b/mainwindow.ui new file mode 100644 index 0000000..b232854 --- /dev/null +++ b/mainwindow.ui @@ -0,0 +1,22 @@ + + + MainWindow + + + + 0 + 0 + 800 + 600 + + + + MainWindow + + + + + + + + diff --git a/sqmtablemodel.cpp b/sqmtablemodel.cpp new file mode 100644 index 0000000..7218701 --- /dev/null +++ b/sqmtablemodel.cpp @@ -0,0 +1,66 @@ +#include "sqmtablemodel.h" + + +SQMTableModel::SQMTableModel(QObject *parent) + : QAbstractTableModel(parent) { +} + +QVariant SQMTableModel::data(const QModelIndex &index, int role) const { + + if (role == Qt::DisplayRole) { + int row = index.row(); + int col = index.column(); + + return sqmMatrix.at(col).at(row); + } + return QVariant(); +} + +void SQMTableModel::SetStartValues(int pBase, int pExp, int pMod) { + base = pBase; + exp = pExp; + mod = pMod; +} + + +std::string SQMTableModel::IntToBinary(int n) { + string bin; + int mask = 1; + while (n != 0) { + bin += (n & mask) == 0 ? "0" : "1"; + n = n >> 1; + } + + return bin; +} + +void SQMTableModel::CalculateSqmMatrix(int startRow) { + string bin = IntToBinary(exp); + int binLen = bin.length(); + + // Initialize bin column + vector colBin; + for (int i = 0; i < binLen; i++) { + colBin.push_back(bin[i] - '0'); + } + sqmMatrix.at(0) = colBin; + + for (int i = startRow; i < binLen; i++) { + if (i == 0) { + // Initialize first row + sqmMatrix.at(1).at(0) = 1; + sqmMatrix.at(2).at(0) = base; + } + else { + // Square Multiply + sqmMatrix.at(1).at(i) = sqmMatrix.at(2).at(i - 1) * sqmMatrix.at(2).at(i - 1); + + if (sqmMatrix.at(0).at(i) == 0) { + sqmMatrix.at(2).at(i) = sqmMatrix.at(1).at(i); + } + else { + sqmMatrix.at(2).at(i) = sqmMatrix.at(1).at(i) * base; + } + } + } +} diff --git a/sqmtablemodel.h b/sqmtablemodel.h new file mode 100644 index 0000000..57e8b3d --- /dev/null +++ b/sqmtablemodel.h @@ -0,0 +1,27 @@ +#ifndef SQMTABLEMODEL_H +#define SQMTABLEMODEL_H +#include +#include + +using namespace std; + +class SQMTableModel : public QAbstractTableModel { + Q_OBJECT +public: + SQMTableModel(QObject *parent = nullptr); + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + + void SetStartValues(int pBase, int pExp, int pMod); + +private: + std::string IntToBinary(int n); + void CalculateSqmMatrix(int startRow); + + int base; + int exp; + int mod; + + vector> sqmMatrix; +}; + +#endif // SQMTABLEMODEL_H