15,905,232 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by carlmack (Top 23 by date)
carlmack
6-Dec-11 2:41am
View
the code submitted was taken from a work sheet exercise, now naturally i would like to understand fully what am doing when a code has errors where to look and what to look for when those errors a given after compiling, so i posted that example for guidance as to how to approach a solution in removing the errors, so far the responses have been good, thank u much
carlmack
5-Dec-11 5:58am
View
// Declarations
class Matrix;
double Det(const Matrix& a);
Matrix Diag(const int n);
Matrix Diag(const Matrix& v);
Matrix Inv(const Matrix& a);
Matrix Ones(const int rows, const int cols);
int Size(const Matrix& a, const int i);
Matrix Zeros(const int rows, const int cols);
/*
* a simple exception class
* you can create an exeption by entering
* throw Exception("...Error description...");
* and get the error message from the data msg for displaying:
* err.msg
*/
class Exception
{
public:
const char* msg;
Exception(const char* arg)
: msg(arg)
{
}
};
class Matrix
{
public:
// constructor
Matrix()
{
//printf("Executing constructor Matrix() ...\n");
// create a Matrix object without content
p = NULL;
rows = 0;
cols = 0;
}
// constructor
Matrix(const int row_count, const int column_count)
{
// create a Matrix object with given number of rows and columns
p = NULL;
if (row_count > 0 && column_count > 0)
{
rows = row_count;
cols = column_count;
p = new double*[rows];
for (int r = 0; r < rows; r++)
{
p[r] = new double[cols];
// initially fill in zeros for all values in the matrix;
for (int c = 0; c < cols; c++)
{
p[r][c] = 0;
}
}
}
}
// assignment operator
Matrix(const Matrix& a)
{
rows = a.rows;
cols = a.cols;
p = new double*[a.rows];
for (int r = 0; r < a.rows; r++)
{
p[r] = new double[a.cols];
// copy the values from the matrix a
for (int c = 0; c < a.cols; c++)
{
p[r][c] = a.p[r][c];
}
}
}
// index operator. You can use this class like myMatrix(col, row)
// the indexes are one-based, not zero based.
double& operator()(const int r, const int c)
{
if (p != NULL && r > 0 && r <= rows && c > 0 && c <= cols)
{
return p[r-1][c-1];
}
else
{
throw Exception("Subscript out of range");
}
}
// index operator. You can use this class like myMatrix.get(col, row)
// the indexes are one-based, not zero based.
// use this function get if you want to read from a const Matrix
double get(const int r, const int c) const
{
if (p != NULL && r > 0 && r <= rows && c > 0 && c <= cols)
{
return p[r-1][c-1];
}
else
{
throw Exception("Subscript out of range");
}
}
// assignment operator
Matrix& operator= (const Matrix& a)
{
rows = a.rows;
cols = a.cols;
p = new double*[a.rows];
for (int r = 0; r < a.rows; r++)
{
p[r] = new double[a.cols];
// copy the values from the matrix a
for (int c = 0; c < a.cols; c++)
{
p[r][c] = a.p[r][c];
}
}
return *this;
}
// add a double value (elements wise)
Matrix& Add(const double v)
{
for (int r = 0; r < rows; r++)
{
for (int c = 0; c < cols; c++)
{
p[r][c] += v;
}
}
return *this;
}
// subtract a double value (elements wise)
Matrix& Subtract(const double v)
{
return Add(-v);
}
carlmack
4-Dec-11 3:40am
View
I am very new to this, topic, fairly and i wand to be finish. so each day i spen here i learn quite a lot. Thank you
carlmack
4-Dec-11 3:36am
View
Can you tell me whats the reason for all these warnings?
carlmack
4-Dec-11 3:35am
View
Ok Original, just a little bit out of it, just trying to get this working properly, and am not being rude , just tired have not slept 4 days almost. I will try to be more alert, dont know by how much
carlmack
4-Dec-11 3:31am
View
YEAH , I UNDERSTAND WAS TRYING TO CUT IS SORRY ....I GET ON THE BORELAND "FUNCTIONS CONTAINING FOR ARE NOT EXPANDED INLINE, AND THAT IS 23 SUCH WARNINGS, STARTING AT LINE 63,1 THEN 82,1 AND THEN 19,1 CONTINUING DOWN. THANKS 4 Z HELP
carlmack
3-Dec-11 16:33pm
View
thank you Ritchie, i just learn a ton more than i have for the last 3 weeks thank you sir
carlmack
3-Dec-11 15:59pm
View
ok i am doing that as we speak
carlmack
3-Dec-11 15:36pm
View
i need to go through the definition once more cause i get 10 errors soon as i include it in the code
carlmack
3-Dec-11 15:33pm
View
class PMatrix{
//A general matrix.
protected:
int m_nRows;
int m_nCols;
int m_nElements;
double * element;
public:
PMatrix(); //Default constructor.
virtual ~PMatrix();
inline virtual int GetNumberRows()const = 0;
inline virtual int GetNumberCols()const = 0;
inline virtual int GetNumberElements()const = 0;
inline const double * GetElements()const{return element;}
inline double * GetNonconstantElements(){return element;}
inline const double * GetRow(int row)const{ASSERT(row >= 0 && row < m_nRows); return element + row * m_nCols;}
inline double * GetNonconstantRow(int row)const{ASSERT(row >= 0 && row < m_nRows); return element + row * m_nCols;}
inline virtual double GetElement(int row, int col)const = 0;
void GetCopyOfElements(double * copy)const;
bool IsZero()const;
bool HasLargeElements(double max)const;
void MeEqualsMeTransposed();
void MeEqualsOther(const PMatrix & other);
void MeEqualsMinusOther(const PMatrix & other);
virtual void MeEqualsMinusMe()const;
void InsertDiagonalSubmatrix(int order, int startRow, int startCol, double diag)const;
void MakeMeZero()const{for(int i = 0; i < m_nElements; ++i)element[i] = 0.0;}
virtual void MeTimesColumnVector(const double * givenVector, double * resultingVector)const = 0;
virtual void RowVectorTimesMe(const double * givenVector, double * resultingVector)const = 0;
virtual void MeTimesMatrix(const PMatrix & Given, PMatrix & Result)const = 0;
virtual void MeTransposedTimesMatrix(const PMatrix & Given, PMatrix & Result)const = 0;
virtual void MeTimesMatrixTransposed(const PMatrix & Given, PMatrix & Result)const = 0;
double MeInnerProductMatrix(const PMatrix & M)const;
virtual void MeEqualsSumOf(const PMatrix & A, const PMatrix & B)const;
virtual void MeEqualsNegativeSumOf(const PMatrix & A, const PMatrix & B)const;
virtual void MeEqualsDifferenceBetween(const PMatrix & A, const PMatrix & B)const;
virtual void MeEqualsMePlus(const PMatrix & other)const;
virtual void MeEqualsMeMinus(const PMatrix & other)const;
virtual void MeEqualsMinusMePlus(const PMatrix & other)const;
virtual void MeEqualsMinusMeMinus(const PMatrix & other)const;
//The following virtual operators are inherited by all derived classes. They are
//implemented in PMatrix.cpp, and can be used as-is, or overriden for efficiency.
virtual void operator+=(const PMatrix & C);
virtual void operator-=(const PMatrix & C);
virtual void operator*=(double dd);
virtual void operator/=(double dd);
//Utility.
virtual ArrayOfStr ReportMatrix(const char * title = NULL, const char * format = NULL)const;
virtual bool CompareMatrix(const PMatrix & m)const;
}; //Class PMatrix
//--------------------------------------------------------------------
#endif // !defined(AFX_PMATRX_H__F4499B64_A4E5_4610_AFF0_3C0E2E369429__INCLUDED_)
carlmack
3-Dec-11 15:17pm
View
well Ritchie it easy for you am learning and learning on my own, ofcourse with the help i get fron you guys a nd the forum in general, how would i input this in my code?
carlmack
3-Dec-11 14:20pm
View
crystal clear Ritchie
thank you
this program is structured to allow for: prompt user to enter information,
this is a provision made in the event the user input elements the result in a not square matrix, hence rather than leaving it to user discretion i have a test to ensure,
carlmack
3-Dec-11 12:59pm
View
can you explain further i am sure i dont follow
carlmack
1-Dec-11 13:29pm
View
Thanks for your kind response, i know my code is long, i am doing it for a course assignment, but more than just getting the help i need to understand because i enjoy working at it so far. I want to write a program to compute Matrices, find the determinant, the co factor do addition and subtraction etc, I want to use a base class call Matrix then some derived classes to assist with displaying and executing the correct sequence of my code, but i am lost, tell the truth, i am not giving up but i would like some help in the direction i should go, oh! my code is in C++ my compiler is Dev C++ and Boreland C++, Thanks for the assistance
carlmack
28-Nov-11 14:49pm
View
oh totally appreciated Stefan_Lang, In the program i use a max size but this program itself allows for the use of smaller size. but i understand what u saying. I was trying to re-write the same code in c++ but using class instead of just function, however i thing i have a little difficulty in the public members and what private members would be, can u give an idea of how to approach it?
carlmack
27-Nov-11 11:36am
View
hahahah well u may not be an electrical engineer but u do programming and thats all am asking, but if you busy thats ok, am sure you will contribute to me being as good as u either directly or otherwise, i will just post this code in the general forum and see what assistance i can get.
BLESS
carlmack
27-Nov-11 11:05am
View
what do i do inorder to post myy entire code without violating the forum regulations?
carlmack
27-Nov-11 10:54am
View
can i post my codes here
carlmack
27-Nov-11 10:49am
View
i dont know if you will have the time to extend a hand is assisting a new comer to this field , when/where applicable,
i am a young electrical engineer just graduated and am trying some of what i learn, so what would take you a day , maybe will take me a month, but i wish to learn this art well, right now i am trying to do this program i need to use in kirchoff;s current and voltage laws to compute variables in atleast 5 branch circuit, i am using craemer's rult to do the computations, and i want someone whoo could look at my codes and give me some advise. also i currently uses Boreland C++ to compile these program cause thats what we were taught but my machine is a 64 bit and so sometimes i cant make it run, even though it compiles, can i sehow u do?
can i send my code and u look at it for me
carlmack
27-Nov-11 10:39am
View
hey guys hahah i am just learning the art, i am just looking how to use this new skillin my daily computation ,but a little flair would not hurt, haha
anyway could u look at my codes and give ma a feed back?
some aspects i took from my text and some from the net, but i knew what i wanted to do, so any assistance would be great.
thank you
carlmack
27-Nov-11 10:34am
View
just wondering/thinking how i can improve my programming skills
this program is to use craemer's rule to compute matrix operations
but i guess i need to sharpen my math skills, i need it to use in kirchoff's laws calculation
carlmack
27-Nov-11 10:28am
View
ok well said, do you normally engage in programming and to what extent?
carlmack
26-Nov-11 9:52am
View
I am trying to get familiar with this forum, from the looks i see here , there is a wealth of experience to be gained . Thanks much all, i want my program to be used to compute matrices operation but before i can even attempt same i need a compiler that will run on my window 7 64 bit machine, secondly i want to write a C++ program using dynamic array hence my attempt. so all i need is guidance . thanks much
Show More