This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Problem with displaying Matrix elements in QT application

Tags: None
(comma "," separated)
warrior4just
Registered Member
Posts
2
Karma
0
Hello everyone

I've worked with Julia Library which is a bit different from Eigen, i've posted this issue in Qt nobody was able to help me, cause not everyone is familar with Eigen library, so i thought i'll post here, if you can help me with this.

The issue i have, is i want to solve a linear system from a randomly generated entries for the matrix class....
I would like to click "generate random" button in QT application which i created, then a specific size matrix is generated, but i can't display them in the QtextEdit (displays strings)

here is the bit of code...

Code: Select all
    void MainWindow::on_pushButton_5_clicked()
    {
        MatrixXd A = MatrixXd::Random(3,3);
        VectorXd b = VectorXd::Random(3,1);
     
        QString text1;
        QString text2;
     
        for (int i; i<=A.rows();i++)
        {
            for (int j;j<=A.cols();j++)
            {
                text1 += QString::number(A(i,j))+ " ";
     
            }
     
            text1 += "\n";
            text2 +=  QString::number(b(i))+ "\n";
        }
     
         ui->textEdit_5->setPlainText(text1);
         ui->textEdit_6->setPlainText(text2);
     
         //    Vector3f x = A.colPivHouseholderQr().solve(b);
    }



I appreciate if you can see where the problem is, is sure is trivial..., but i convert the double value from the Eigen's matrix class to string, but i don't know how to display them....

Thanks a lot
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
This has nothing to do with Eigen, but the line:
Code: Select all
for (int i; i<=A.rows();i++)

is wrong (i is not initialised, and i goes out of bounds). It should be:
Code: Select all
for (int i=0; i<A.rows();i++)

Same for the second for loop.
warrior4just
Registered Member
Posts
2
Karma
0
ggael...., that was retarded of me not to initialize. ;D
Thanks a lot


Bookmarks



Who is online

Registered users: Baidu [Spider], Bing [Bot], Google [Bot], Yahoo [Bot]