| 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_namespaceHRESULT 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 |
|
|