 |
|
 |
First of all I would like to give Roger Allen a big star for the matrix code.
For all of you who want the code working in MSVC10 I have converted and tested it.
Just give me a reply and I will send the code to you.
/Patrik
|
|
|
|
 |
|
 |
can you send me your code, please.
|
|
|
|
 |
|
 |
I added Matrix.h and matrix.cpp to my MFC project in vc++ but it gave me over 25 errors when compliling:
Error 1 error C2664: 'strcpy' : cannot convert parameter 2 from 'CString' to 'const char *' e:\thesis\projects\testimageapp\matrix.cpp 996
Error 2 error C2665: 'AfxMessageBox' : none of the 2 overloads could convert all the argument types e:\thesis\projects\testimageapp\matrix.cpp 1035
Error 3 error C2665: 'AfxMessageBox' : none of the 2 overloads could convert all the argument types e:\thesis\projects\testimageapp\matrix.cpp 1038
Error 4 error C2665: 'AfxMessageBox' : none of the 2 overloads could convert all the argument types e:\thesis\projects\testimageapp\matrix.cpp 1041
Warning 5 warning C4996: 'CFileException::generic' was declared deprecated e:\thesis\projects\testimageapp\matrix.cpp 1043
Error 6 error C2665: 'AfxMessageBox' : none of the 2 overloads could convert all the argument types e:\thesis\projects\testimageapp\matrix.cpp 1044
Error 7 error C2665: 'AfxMessageBox' : none of the 2 overloads could convert all the argument types e:\thesis\projects\testimageapp\matrix.cpp 1047
Error 8 error C2665: 'AfxMessageBox' : none of the 2 overloads could convert all the argument types e:\thesis\projects\testimageapp\matrix.cpp 1050
Error 9 error C2665: 'AfxMessageBox' : none of the 2 overloads could convert all the argument types e:\thesis\projects\testimageapp\matrix.cpp 1053
Error 10 error C2665: 'AfxMessageBox' : none of the 2 overloads could convert all the argument types e:\thesis\projects\testimageapp\matrix.cpp 1056
Error 11 error C2665: 'AfxMessageBox' : none of the 2 overloads could convert all the argument types e:\thesis\projects\testimageapp\matrix.cpp 1059
Error 12 error C2665: 'AfxMessageBox' : none of the 2 overloads could convert all the argument types e:\thesis\projects\testimageapp\matrix.cpp 1062
Error 13 error C2665: 'AfxMessageBox' : none of the 2 overloads could convert all the argument types e:\thesis\projects\testimageapp\matrix.cpp 1065
Error 14 error C2664: 'atof' : cannot convert parameter 1 from 'CString' to 'const char *' e:\thesis\projects\testimageapp\matrix.cpp 1101
Error 15 error C2665: 'AfxMessageBox' : none of the 2 overloads could convert all the argument types e:\thesis\projects\testimageapp\matrix.cpp 1133
Error 16 error C2665: 'AfxMessageBox' : none of the 2 overloads could convert all the argument types e:\thesis\projects\testimageapp\matrix.cpp 1136
Error 17 error C2665: 'AfxMessageBox' : none of the 2 overloads could convert all the argument types e:\thesis\projects\testimageapp\matrix.cpp 1139
Warning 18 warning C4996: 'CFileException::generic' was declared deprecated e:\thesis\projects\testimageapp\matrix.cpp 1141
Error 19 error C2665: 'AfxMessageBox' : none of the 2 overloads could convert all the argument types e:\thesis\projects\testimageapp\matrix.cpp 1142
Error 20 error C2665: 'AfxMessageBox' : none of the 2 overloads could convert all the argument types e:\thesis\projects\testimageapp\matrix.cpp 1145
Error 21 error C2665: 'AfxMessageBox' : none of the 2 overloads could convert all the argument types e:\thesis\projects\testimageapp\matrix.cpp 1148
Error 22 error C2665: 'AfxMessageBox' : none of the 2 overloads could convert all the argument types e:\thesis\projects\testimageapp\matrix.cpp 1151
Error 23 error C2665: 'AfxMessageBox' : none of the 2 overloads could convert all the argument types e:\thesis\projects\testimageapp\matrix.cpp 1154
Error 24 error C2665: 'AfxMessageBox' : none of the 2 overloads could convert all the argument types e:\thesis\projects\testimageapp\matrix.cpp 1157
Error 25 error C2665: 'AfxMessageBox' : none of the 2 overloads could convert all the argument types e:\thesis\projects\testimageapp\matrix.cpp 1160
Error 26 error C2665: 'AfxMessageBox' : none of the 2 overloads could convert all the argument types e:\thesis\projects\testimageapp\matrix.cpp 1163
Error 27 error C2664: 'void ATL::CStringT<basetype,stringtraits>::Format(const wchar_t *,...)' : cannot convert parameter 1 from 'const char [3]' to 'const wchar_t *' e:\thesis\projects\testimageapp\matrix.cpp 1184
what is wrong with it? what should I do to fix it?
|
|
|
|
 |
|
 |
Hi, I can not download the sources files from the link. Can you give me a copy. My e-mail address is: whb111@uestc.edu.cn.
Thanks,
Best regards.
Wang Hongbing
|
|
|
|
 |
|
 |
i want to add the CNatrix class into my dll proj but its showing error.
why the CObject is kept as base.
can i use this class in proj other than MFC's
My small attempt...
|
|
|
|
 |
|
 |
Hi!
Here is a better version of the serialization function for class CMatrix.
The version from the original class is indeed more clear, but if you intend to use it in an application and use high order matrices this can lead to unneccessary operations, such as loops and assignments.
void CMatrix::Serialize(CArchive& ar)
{
CObject::Serialize(ar);
if(ar.IsStoring())
{
ar << header1;
ar << header2;
ar << version;
ar << m_NumColumns;
ar << m_NumRows;
ar.Write(m_pData, sizeof(double) * m_NumColumns * m_NumRows);
}
else
{
long h1, h2;
int ver;
ar >> h1;
ar >> h2;
if(h1 != header1 || h2 != header2)
{
AfxThrowArchiveException(CArchiveException::badClass, NULL);
}
ar >> ver;
ASSERT(ver == version);
ar >> m_NumColumns;
ar >> m_NumRows;
ar.Read(m_pData, sizeof(double) * m_NumColumns * m_NumRows);
}
}
Variables header1, header2 and version are defined in "Matrix.h":
#define header1 0x434d6174
#define header2 0x72697843
#define version 1
I think it's a good idea to separate the signature and version of the object beeing serialized from the serialization code so that when you modify it, you won't have to go through all the serialization code to update the values, you simply modify them where they are declared.
That's it.
It doesn't do much but I am working a lot with serialization and I thought that I can give a helping hand on updating this class.
I am in love with VC++
|
|
|
|
 |
|
 |
Hi!
Here is how you can use this class In Visual C++ 6.0.
1) Open Visual C++ 6.0 application.
2) Select File -> New -> Win32 Console Application. Select the desired location for your project and give it a name, let's say MatrixPrj. Click OK.
3) In the dialog box that appears select option "An application that supports MFC" and click Finish.
4) In the last step click OK to finish.
5) Copy the files "Matrix.h" and "Matrix.cpp" in your project's folder.
6) Select Project -> Add To Project -> Files. Select the files "Matrix.h" and "Matrix.cpp" and click OK. Now the two files are added to your project.
7) Go to file "Matrix.h" where CMatrixHelper class is defined, go to function void operator=(CMatrixHelper& other) and replace the following line of code:
m_pMatrixConst = other.m_Col;
with this one:
m_pMatrixConst = other.m_pMatrixConst;
8) Now compile the entire project and you are ready to use the functionality of this class.
I am in love with VC++
|
|
|
|
 |
|
 |
How about Select File->New -> MFC AppWizard(exe)
|
|
|
|
 |
|
 |
It took me about 30 seconds for inverse a 8x8 matrix..
why?
Might give it up if no solution for it..
|
|
|
|
 |
|
|
 |
|
 |
I was interested in the suggestion of eliminating the helper class below, but as a beginner I am not sure how to implement the suggestion. Does anyone have updated matrix.h and matrix.cpp incorporating the suggestion? Hopefully it would also eliminate the error LNK2001: unresolved external symbol __endthreadex and __beginthreadex. Thank you.
cwb
|
|
|
|
 |
|
 |
I fixed the compile error and then received the following link errors. From reading through the F1 help on LNK2001, it sounds like playing with the project compile or link settings could potentially fix the errors (or possibly produce more subtle errors). Any advice on these and possibly other problems down the road?
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex
cwb
|
|
|
|
 |
|
 |
Hi....
I tried to create a CMatrix object using CMatrix(); but the compiler could not compile saying there is errors as follows ;
Linking...
Global.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall CMatrix::~CMatrix(void)" (??1CMatrix@@UAE@XZ)
Global.obj : error LNK2001: unresolved external symbol "public: __thiscall CMatrix::CMatrix(void)" (??0CMatrix@@QAE@XZ)
Debug/painter.exe : fatal error LNK1120: 2 unresolved externals
Anybody that can help me resolve the following errors ?? Thanks alot cos i just started learning how to program in visual c....
|
|
|
|
 |
|
 |
Hi!
I'm interested in using the matrix class, however and since I'm a newbie I don't know how to use it... can you send me a small example for Microsoft Visual C++ 6.0, creating and adding 2 matrixes?
jolival@av.it.pt
Thanks,
Best regards,
João Olival
|
|
|
|
 |
|
 |
Funny Business
A man is opening a restaurant and he asks one of his workers to come up with a name for it.
The man tells Al, one of his workers, that he will name the resaurant after the first thing Al sees when he goes out the door.
Al walks outside and the first thing he saw was a girl named Lucy and he saw her legs. He told the man, and so the restaurant was named Lucy's Legs. The man was so impressed that he said the next day Al could get a free drink.
The next day Al comes a bit early and a policeman walks by and notices Al waiting there. The policeman asks, "What are you doing?"
Al says, "I'm waiting for Lucy's legs to open so I can get a drink."
|
|
|
|
 |
|
 |
Hi,
How are you? Your Class Matrix is very interesting i like a lot.
But i dont undenstand the way to introduce the values in matrix
You put *mpData and you put that use the CMatrixHelper to simulate [][] but dont put any example
Please Help me
Thanks very much
|
|
|
|
 |
|
 |
as I use the function CMatrix::Invert(),I found sometimes it doesn't work well at all,cannot calculate exactly real Invert Matrix,sometimes it is right,sometimes it is wrong,is there any problem in your programming?please check it and give me the answer
|
|
|
|
 |
|
 |
to rogen allen...
im very weak in c++ programming..ihope u can help me to solve my prob..
how to use cmatrix and can u give me some tutorial..then can u give me some example source code to prove eigen value and vector prob in c++
need for help
|
|
|
|
 |
|
 |
hi all...i m a beginner in programming..so i tried to get benifit of the code of matrix class written by Roger Allen but there was an error coz he didnt attach "stdafx.h" with his code...so if any one can help me with that...tnx
Madoo
|
|
|
|
 |
|
 |
Can anybody help me??
When comiling the code in VC7, I've got this:
Matrix.cpp(1022): error C2316: 'CFileException &' : cannot be caught as the destructor and/or copy constructor are inaccessible
Thx...
|
|
|
|
 |
|
 |
I think you should change to: CFileException*e, and e->cause
|
|
|
|
 |
|
 |
This is the code i am having in visual c++ 6. Matrix.h & matrix.cpp are in current project folder and included in project.
#include
#include "matrix.cpp"
void main()
{
CMatrix:: A();
}
But i am getting an error that
matrix.h(191) :error C2440: '=' : cannot convert from 'int' to 'const class CMatrix *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
Please tell me what to be done.
Thanks
Nagarajan
|
|
|
|
 |
|
 |
Now that probelem is correted by explicit type casting.. The program compiles without any error.
#include
#include "matrix.cpp"
using namespace std;
void main()
{
CMatrix A(3,4);
}
But while linking i get 151 errors.
like
Matrix.obj : error LNK2005: "public: static class CObject * __stdcall CMatrix::CreateObject(void)" (?CreateObject@CMatrix@@SGPAVCObject@@XZ) already defined in mat.obj
Matrix.obj : error LNK2005: "public: virtual struct CRuntimeClass * __thiscall CMatrix::GetRuntimeClass(void)const " (?GetRuntimeClass@CMatrix@@UBEPAUCRuntimeClass@@XZ) already defined in mat.obj
Matrix.obj : error LNK2005: "class CArchive & __stdcall operator>>(class CArchive &,class CMatrix * &)" (??5@YGAAVCArchive@@AAV0@AAPAVCMatrix@@@Z) already defined in mat.obj
Matrix.obj : error LNK2005: "public: __thiscall CMatrix::CMatrix(void)" (??0CMatrix@@QAE@XZ) already defined in mat.obj
Matrix.obj : error LNK2005: "public: __thiscall CMatrix::CMatrix(class CMatrix const &)" (??0CMatrix@@QAE@ABV0@@Z) already defined in mat.obj
Matrix.obj : error LNK2005: "public: __thiscall CMatrix::CMatrix(int,int)" (??0CMatrix@@QAE@HH@Z) already defined in mat.obj
Matrix.obj : error LNK2005: "public: __thiscall CMatrix::CMatrix(int,bool)" (??0CMatrix@@QAE@H_N@Z) already defined in mat.obj
Matrix.obj : error LNK2005: "public: __thiscall CMatrix::CMatrix(struct tagVARIANT &)" (??0CMatrix@@QAE@AAUtagVARIANT@@@Z) already defined in mat.obj
Matrix.obj : error LNK2005: "public: virtual __thiscall CMatrix::~CMatrix(void)" (??1CMatrix@@UAE@XZ) already defined in mat.obj
Matrix.obj : error LNK2005: "public: virtual void __thiscall CMatrix::Dump(class CDumpContext &)const " (?Dump@CMatrix@@UBEXAAVCDumpContext@@@Z) already defined in mat.obj
Matrix.obj : error LNK2005: "public: virtual void __thiscall CMatrix::AssertValid(void)const " (?AssertValid@CMatrix@@UBEXXZ) already defined in mat.obj
Matrix.obj : error LNK2005: "public: virtual void __thiscall CMatrix::Serialize(class CArchive &)" (?Serialize@CMatrix@@UAEXAAVCArchive@@@Z) already defined in mat.obj
Matrix.obj : error LNK2005: "private: double * __thiscall CMatrix::AllocateMemory(int,int)" (?AllocateMemory@CMatrix@@AAEPANHH@Z) already defined in mat.obj
Matrix.obj : error LNK2005: "public: class CMatrix & __thiscall CMatrix::operator=(class CMatrix const &)" (??4CMatrix@@QAEAAV0@ABV0@@Z) already defined in mat.obj
Matrix.obj : error LNK2005: "public: bool __thiscall CMatrix::operator==(class CMatrix const &)const " (??8CMatrix@@QBE_NABV0@@Z) already defined in mat.obj
Matrix.obj : error LNK2005: "public: class CMatrix __thiscall CMatrix::operator+(class CMatrix const &)const " (??HCMatrix@@QBE?AV0@ABV0@@Z) already defined in mat.obj
Matrix.obj : error LNK2005: "public: class CMatrix __thiscall CMatrix::operator-(class CMatrix const &)const " (??GCMatrix@@QBE?AV0@ABV0@@Z) already defined in mat.obj
Matrix.obj : error LNK2005: "public: class CMatrix __thiscall CMatrix::operator*(class CMatrix const &)const " (??DCMatrix@@QBE?AV0@ABV0@@Z) already defined in mat.obj
Please help me...
thanks
|
|
|
|
 |
|
 |
CMatrix CMatrix::operator*(const CMatrix &other) const
{
// first check for a valid multiplication operation
if (m_NumColumns != other.m_NumRows)
throw "Matrices do not have common size" ;
// now that we know that the operation is possible
ASSERT(FALSE == IsBadReadPtr(other.m_pData, sizeof(double) * other.m_NumColumns * other.m_NumRows)) ;
// construct the object we are going to return
CMatrix result(other.m_NumColumns, m_NumRows);
// e.g.
// [A][B][C] [G][H] [A*G + B*I + C*K][A*H + B*J + C*L]
// [D][E][F] * [I][J] = [D*G + E*I + F*K][D*H + E*J + F*L]
// [K][L]
//
double value ;
for (int i = 0 ; i < result.m_NumColumns ; i++)
{
for (int j = 0 ; j < result.m_NumRows ; j++)
{
value = 0.0 ;
for (int k = 0 ; k < m_NumColumns ; k++)
{
value += GetElement(k,j) * other.GetElement(k,i) ;
}
result.SetElement(i, j, value) ;
}
}
return result ;
}
Jon Gould
|
|
|
|
 |
|
 |
Or even this.
CMatrix CMatrix::operator*(const CMatrix &other) const
{
// first check for a valid multiplication operation
if (m_NumColumns != other.m_NumRows)
throw "Matrices do not have common size" ;
// now that we know that the operation is possible
ASSERT(FALSE == IsBadReadPtr(other.m_pData, sizeof(double) * other.m_NumColumns * other.m_NumRows)) ;
// construct the object we are going to return
CMatrix result(other.m_NumColumns, m_NumRows);
// e.g.
// [A][B][C] [G][H] [A*G + B*I + C*K][A*H + B*J + C*L]
// [D][E][F] * [I][J] = [D*G + E*I + F*K][D*H + E*J + F*L]
// [K][L]
//
double value ;
for (int i = 0 ; i < result.m_NumColumns ; i++)
{
for (int j = 0 ; j < result.m_NumRows ; j++)
{
value = 0.0 ;
for (int k = 0 ; k < m_NumColumns ; k++)
{
value += GetElement(k,j) * other.GetElement(i,k) ;
}
result.SetElement(i, j, value) ;
}
}
return result ;
}
|
|
|
|
 |