Bluebit Software
Bluebit Software Support Forum
 Home          Members     Calendar     Who's On

Welcome Guest ( Login | Register )
        



Using LU in .NET and ActiveX Expand / Collapse
Message
Posted Tuesday, August 28, 2007 2:49 AM Post #428
 

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie
To start with, I'm totally new to this.

One of my colleagues made code in .NET using the LU class.

LU lu = new LU(mtx_l);
if (lu.IsSingular) return false;
Matrix res_u = lu.Solve(mtx_u);

I'm now trying to convert this to C++ using the ActiveX version. I don't see the LU class, but only ad a method to Matrix.

Can anyone help me with an example on how to use the LU method in ActiveX?

-cpede

Posted Tuesday, August 28, 2007 3:38 AM Post #429
 

Bluebit SupportBluebit SupportBluebit SupportBluebit SupportBluebit SupportBluebit SupportBluebit SupportBluebit Support
The ActiveX component uses a different interface and there is no LU object. You may use the LU method of the Matrix object. Please refer to the VB example given in the documentation:

http://www.bluebit.gr/matrix/version_31/LU.htm

It should not be difficult to convert the above code in C++.

Trifon Triantafillidis

Lead Developer

Bluebit Software

Posted Monday, September 03, 2007 9:52 AM Post #430
 

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie
It's not entirely clear how I should convert the Basic code to C++. For example, in C# we can call the solve function to return the result from an LU decomp. In C++ it works another way. Can you give me a little code clip that complements in C#:

LU lu = new LU(mtx_l)
Matrix res_u = lu.Solve(mtx_u);

-cpede

Posted Tuesday, September 04, 2007 5:10 AM Post #431
 

Bluebit SupportBluebit SupportBluebit SupportBluebit SupportBluebit SupportBluebit SupportBluebit SupportBluebit Support
First of all there are two distinct products you may use.

".NET Matrix Library" (NML) is intended to be used with .NET languages such as VB.NET C# and managed C++ .

"Matrix ActiveX Component" (MaXC) is targeted to VB6 but it can be used by all languages supporting COM such as native C++.

I assume you want to use MaXC with C++. If yes it may help you the C++ project that is found in under the "Samples" directory.

I have modify the example in order to perform LU decomposition and here is the code:


#include "stdafx.h"
#include "iostream.h"
#import "bluebitmatrix31.dll" no_namespace

HRESULT MatrixLU()
{
 IMatrix *A;

 long N  = 6;

 HRESULT hr;
 hr = ::CoCreateInstance(__uuidof(Matrix), NULL, CLSCTX_INPROC, __uuidof(IMatrix), (void**)&A);
 if(FAILED(hr))
  return hr; 

 A->Size(N, N);
 A->FillRandom(0, 10, 0);


 cout << "===============================" << endl;
 cout << "Matrix A =" << endl;
 cout << A->GetString(3, _bstr_t("")) << endl;
 cout << "===============================" << endl;


 //Declare 2 matrix variables that will hold
 //the L and U parts of LU decomposition
 IMatrix *L, *U;
 hr = ::CoCreateInstance(__uuidof(Matrix), NULL, CLSCTX_INPROC, __uuidof(IMatrix), (void**)&L);
 if(FAILED(hr))
  return hr;
 hr = ::CoCreateInstance(__uuidof(Matrix), NULL, CLSCTX_INPROC, __uuidof(IMatrix), (void**)&U);
 if(FAILED(hr))
  return hr;

 VARIANT * perIndex ;
 perIndex = NULL;
 long perSign = 0;
 

 A->LU( &L, &U, perIndex, &perSign );
 

 cout << endl;
 cout << "===============================" << endl;
 cout << "Matrix L =" << endl;
 cout << L->GetString(3, _bstr_t("")) << endl;
 cout << "===============================" << endl;


 cout << endl;
 cout << "===============================" << endl;
 cout << "Matrix U =" << endl;
 cout << U->GetString(3, _bstr_t("")) << endl;
 cout << "===============================" << endl;


 if(A)
  A->Release();
 if(L)
  L->Release();
 if(U)
  U->Release();

 return hr;
}

int main(int argc, char* argv[])
{
 ::CoInitialize(NULL);
 MatrixLU();
 //cout << "Please press return to exit";
 //cin.get();
 CoUninitialize();    // clearup
 return 0;
}



Trifon Triantafillidis

Lead Developer

Bluebit Software

Posted Friday, September 07, 2007 5:35 AM Post #432
 

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie
That I understand, but how do I do the Solve method in the .NET LU is not covered.

Having the matrix to LU I can use:

mtx->LU(&l,&u,perIndex,&perSign);

but then I need to do the Solve against another matrix, using the l and u results from the decomposition? How do I do that?

-cpede

Posted Friday, September 07, 2007 6:31 AM Post #433
 

Bluebit SupportBluebit SupportBluebit SupportBluebit SupportBluebit SupportBluebit SupportBluebit SupportBluebit Support
There is not a method that directly supports this in MaXC but you may write your own code. The way to do this is described here:

http://en.wikipedia.org/wiki/LU_decomposition#Applications

It is true that our another product .NET Matrix Library supports this directly with its LU.Solve method.

 

 

Trifon Triantafillidis

Lead Developer

Bluebit Software

« Prev Topic | Next Topic »


Reading This Topic Expand / Collapse
Active Users: 1 (1 guest, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: Trifon

Permissions Expand / Collapse

All times are GMT -5:00, Time now is 11:56am

Powered by InstantForum.NET v4.1.4 © 2010
Execution: 0.219. 8 queries. Compression Disabled.
.NET Matrix Library