Help solve a problem with importing a function from a dll - page 9

 

М... yeah... that's a bummer... with C++ programming in Bilder... Man, lots of errors again :'-(

:-) this svd decomposition has already consumed me so much time, and it looks like there's no end in sight.

Sorry for the immodest question, but could you do the job for an N-th fee?

Honestly, I'm getting tired of fighting it... I've been on this forum since September 2, and how much I've been struggling before that... Oooh...

Of course, I'll study C++ in the future, but it will take some time.

Really hoping for your help.

 

This is what klot's singular transformation function was:

at https://www.mql5.com/ru/code/7359

>> void fastsingular( double X[],int n,int l,int s,double &Y[])

I don't quite understand what kind of calculations you want to do

with 2-dimensional matrices.

.

Try describing the problem.

If it makes sense to me, I will help you.

.

I need to see step by step:

Fill in a 3-by-3 matrix with this, send it to that,

we should get something.

To move to larger matrices is a matter of technique.

 
Pardon my immodest question, but would you be able to do the job for an N-th fee? <br / translate="no">

Good question :-).

 

OK, let me try to explain...

I was looking at klot's MQL code. At first, when I found the link, I was very happy, but after understanding the code and thinking about what I want, I realized that it's not exactly what I want...

It's a bisection-based search of eigennumbers. After reading some literature, I understood that this algorithm is good when we only find a part of all possible eigenvalues.

But if a square matrix is quite large, say, 1000x1000, finding all eigenvalues through bisections is inefficient and this is where the principle of modern algorithms of singular decomposition comes into play - leading a matrix to a bidiagonal form followed by its diagonalization by the QR algorithm. This is the text I bring from the site http://alglib.sources.ru/. Further there is the following sentence: This simple scheme is quite operable, but it can be improved by making an addition which will noticeably increase speed of the program. The scheme of the improved algorithm described below is almost completely borrowed from the LAPACK package (xGESVD subroutine). Full description of the algorithm: http://alglib.sources.ru/matrixops/general/svd.php

That is, for my tasks I need a fast algorithm, working with large matrices of 1000x1000 or even more... and I need exactly ALL singular values together with vectors, i.e. full decomposition. That's why I settled on http://alglib.sources.ru/ library. Especially, since there's already some ready-made C++ code in it. There's a 300 line algorithm there, but it's slower than the 3000 line code. At first I tried to learn how to work with dll, so that I could compile my own dll, but it didn't work. Then I tried to rewrite it from C++ to MQL, but it also appeared to be quite difficult for me to figure out the algorithm and translate it into another language. After that I decided to go back to dll through the forum and ask for help from the professionals, because this version seems to be more universal, don't you think? Besides, as I understand it, MQL5 is about to be released. It is unknown what the compatibility with MQL4 will be. Therefore, it would probably be better to implement the idea through a dll. I would like to know your opinion on this matter.

Since the dimensionality of the square matrix will be unknown at the input, I suggest that the 2-dimensional matrix be implemented as a one-dimensional matrix, and once the dimensionality is known, use the ArrayResize function to fill it in. And that would be the input. Then it is converted to ap::real_2d_array for input to rmatrixsvd. There's a method there:

void setbounds(int iLow1, int iHigh1, int iLow2, int iHigh2)
Allocation of memory for the array. This removes the old array contents and frees the memory that was allocated for it, then allocates a new, separate memory area with the size of (iHigh1-iLow1+1)*(iHigh2-iLow2+1) elements.
Numbering of elements in the new array by the first dimension starts with iLow1 and ends with iHigh1, similarly for the second dimension.
The contents of the new array are undefined.

I.e., I think it's a very convenient method in my opinion, when the size of the array is not known in advance by either the 1st or 2nd dimension.

Then the rmatrixsvd function itself should be calculated which outputs and gives singular numbers and singular vectors in 2-dimensional matrices, which are also converted into one-dimensional matrices and already exported into MQL for further processing.

That seems to be all. I think I haven't forgotten anything.

 

It's clear, you really want to work with a complex variant.

.

You said that you have a test case.

In which you need to fill in a 3 by 3 matrix.

And you know the result.

.

Now you're going to tell me what's supposed to go

to the function rmatrixsvd, and what it should output.

.

I want specific numbers.

 

Examples

Although it is probably better to use the second example to check. In the first one, the eigennumbers are counted. But in principle logically, if we put there a 3x3 matrix, we should get roots of eigennumbers on the diagonal, i.e. singular values, in descending order

Files:
jgdwni.rar  18 kb
 

You could, in principle, look for other examples to check... If these examples don't satisfy you, I'll look for other examples. So that we know for sure that the algorithm works properly...

 

From the description of svd.cpp:

Output parameters:
W - contains singular values ordered in descending order.
U - if UNeeded=0, does not change. Left singular vectors
are not calculated.
if UNeeded=1, contains left singular vectors (the first
min(M,N) columns of matrix U). An array with numbered elements
[0...M-1, 0...Min(M,N)-1].
if UNeeded=2, contains the full matrix U. An array with numbered elements [0.
Numbered array of elements [0..M-1, 0..M-1].
VT - if VTNeeded=0, it is not changed. The right singular vectors
are not calculated.
if VTNeeded=1, it contains the right singular vectors
(the first min(M,N) rows of matrix V^T). The array with numbering
of elements [0...min(M,N)-1, 0...N-1].
if VTNeeded=2, contains full matrix V^T. Array with
by numbering the elements [0..N-1, 0..N-1].

 
You look at all the materials, descriptions, codes... the scope of work... and how much you'll end up pricing your work and we'll discuss it with you. I'd like to then get the source code in addition to the finished working dll...
 
I have high hopes for you!
Reason: