Posted Monday, October 01, 2007 8:55 PM
|
|
|
|
| Hi, I am trying to use your product to find the best fit parabola for data we have collected in a C++ .NET 2003 Unmanaged code program. Below is my code: ::CoInitialize(NULL); hr = ::CoCreateInstance( __uuidof(Matrix), NULL, CLSCTX_INPROC, __uuidof(IMatrix), (void**)&pLftMatrix);if(FAILED(hr))return result;hr = ::CoCreateInstance( __uuidof(Matrix), NULL, CLSCTX_INPROC, __uuidof(IMatrix), (void**)&pRtMatrix);if(FAILED(hr))return result;//Set the Left Matrix sizepLftMatrix->Size(nDataPts + 1, 3); //Set the Right Matrix sizepRtMatrix->Size(nDataPts + 1, 1); //Fill the matrices with datafor (i = 0; i <= nDataPts; i++){ pLftMatrix->Item[i][0] = 1; pLftMatrix->Item[i][1] = zPos[i]; pLftMatrix->Item[i][2] = zPos[i] * zPos[i]; pRtMatrix->Item[i][0] = thickness[i]; } pTLftMatrix = pLftMatrix->Transpose(); /*My program dies here. The call pTLftMatrix->Cols causes an exception. What am I doing wrong? Also How can I capture the exceptions. I have a catch for : catch (_com_error& e) But it doesn't catch it.Below is the rest of my code.*/ errMsg.Format("TLeftMatrix Cols = %s", pTLftMatrix->Cols); errMsg.Format("LeftMatrix Rows = %s", pLftMatrix->Rows); if(pTLftMatrix->Cols == pLftMatrix->Rows) { tempPtr = pTLftMatrix->Times(&pLftMatrix); p3X3LftMatrix = tempPtr->Clone(); } if(pTLftMatrix->Cols == pRtMatrix->Rows) { tempPtr = pTLftMatrix->Times(&pRtMatrix); p3X1RtMatrix = tempPtr->Clone(); } pSolveMatrix = p3X3LftMatrix->SolveGauss(&p3X1RtMatrix); result.thickness = pSolveMatrix->Item[0][0] - (pSolveMatrix->Item[1][0] * pSolveMatrix->Item[1][0] / 4 * pSolveMatrix->Item[2][0]); result.zPos = -pSolveMatrix->Item[1][0] / 2 * pSolveMatrix->Item[2][0]; result.density = 0; result.Successful = true; if(pLftMatrix) pLftMatrix->Release(); if(pRtMatrix)pRtMatrix->Release(); Do you have more examples for using the ActiveX component with C++? Thanks Diane
|
|
Posted Tuesday, October 02, 2007 12:02 PM
|
|
|
|
| Hello, In the "Samples\C++ Demo" folder (default install location "C:\Program Files\Matrix ActiveX Component 3.1\Samples\C++ Demo" ) we have a C++ project which demonstrates the use of MaXC with C++. In order to set a matrix element you should use: A->PutItem( row, col, val);
Trifon Triantafillidis | Lead Developer |
|
|
|
Posted Tuesday, October 02, 2007 3:39 PM
|
|
|
|
| Hi Your suggestion was helpful. But I have already looked at that example. It is very limited. I set the items using SetItem(long, long, double)? When I do a GetString(long, linedelimitors), I don't get the matrix back. CString temp; temp.Format("%s", A->GetString(5, "")); Is there some help for the C++ function calls? Cheers Marmot
|
|
Posted Tuesday, October 02, 2007 4:47 PM
|
|
|
|
| Hi, You know I am creeping along here. And I am wondering if some of my troubles are related to the program not recognizing our registered copy of the program. pMatrix is the transpose of pMatrix2 pMatrix2 is a 10 X 3 matrix and pMatrix is a 3 X 10 matrix and pMatrix3 should be a 3 X 3 matrix. pMatrix3 = pMatrix->Times(&pMatrix2); pMatrix3->GetCols(); //This causes an exception So what am I doing wrong? Thanks Marmot
|
|
Posted Friday, October 05, 2007 1:30 PM
|
|
|
|
| I finally got the program to work. I declared a IMatrixPtr tempPtr; tempPtr = pLeftMatrix->Transpose(&pRtMatrix) pTLftMatrix = tempPtr.Detach(); Cheers Marmot
|
|
|
|