473,325 Members | 2,308 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Can help me with the coding?

24
/*
IsScalarMatrix
---------------
Check if a Matrix is a Scalar matrix
where: diagonal elements all contain the same scalar aij.
Return (!false == true,!true == false)
*/
bool CDblMatrix::IsScalarMatrix()
{
int nRows = 0, nCols = 0;
double temp;


if (m_nCols == m_nRows)
{
temp = m_ppData[0][0];
for (nRows = 0; nRows < m_nRows; nRows++)
{
for (nCols = 0; nCols < m_nCols; nCols++)
{
if ( nRows && nCols == 0)

{
if(((nRows != nCols) && (m_ppData[nRows][nCols])) != 0)
{
cout<< "The matrix is not a Scalar Matrix"<< endl;
return false;
}
else if (((nRows == nCols) && (m_ppData[nRows][nCols])) != temp)
{
cout<< "The matrix is not a Scalar Matrix"<< endl;
return false;
}

}
else
{
cout<< "The matrix is a Scalar Matrix"<< endl;
return true;
}


}
}

}
else
{
cout<< "The matrix is not a square matrix."<< endl;
return false;
}

}


Hi i am writing a code for the scalar matrix. But when i did the testing i got problem...as those are not scalar matrix but it was detected as scalar...so can u help me please...thank you
Oct 19 '06 #1
3 1497
D_C
293 100+
You only need nRows, or nCols, not both. Replace
Expand|Select|Wrap|Line Numbers
  1. for (nRows = 0; nRows < m_nRows; nRows++)
  2. {
  3.   for (nCols = 0; nCols < m_nCols; nCols++)
  4.   {
  5.     ...
  6.   }
  7. }
by
Expand|Select|Wrap|Line Numbers
  1. for(nRows = 1; nRows < m_nRows; nRows++)
  2. {
  3.   if( matrix[nRows][nRows] != matrix[0][0] )
  4.     // not a scalar matrix
  5. }
  6. // is a scalar matrix
Oct 19 '06 #2
cool17
24
oh ok..thank you
Oct 19 '06 #3
hey ...how to convert a given matrix to a scalar matrix,we can apply row and col operation only when we know the variables but if i want to accept the variables at run time??/
Jan 5 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: ganesan | last post by:
Hi Guys, Could any one knows the best coding standards styles(with variable declarations for c#) . and if any links or site with the best coding standards for .NET send me those links regards...
4
by: dotNetDave | last post by:
About three weeks ago I released the first .NET coding standards book titled "VSDN Tips & Tricks .NET Coding Standards". Here is what the famous author/ speaker Deborah Kurata says about it: ...
0
by: Berthold Höllmann | last post by:
I have a default coding header # -*- coding: iso-8859-15 -*- in my python files. I now have Problems with this settings. I swithched to Python 2.4.1 under Windows. When I import files with the...
144
by: Natt Serrasalmus | last post by:
After years of operating without any coding standards whatsoever, the company that I recently started working for has decided that it might be a good idea to have some. I'm involved in this...
7
by: Ralph Lund | last post by:
Hi. I am starting a new project with C#. I am searching for "good" coding conventions. I know that there are some coding conventions from microsoft, (but they are very extensive and not clear)....
13
by: benben | last post by:
Is there an effort to unify the c++ coding standard? Especially identifier naming. Not a big issue but it would be annoying to have to incorporate different coding styles simultaneously when...
7
by: Robert Seacord | last post by:
The CERT/CC has just deployed a new web site dedicated to developing secure coding standards for the C programming language, C++, and eventually other programming language. We have already...
3
by: editormt | last post by:
A recent poll asked if programming standards are used by development organisations... and if they are controlled. None: 20% Yes, but without control: 49% Yes, with control: 31% Participants:...
0
by: pat | last post by:
CodeCheck Coding Standard's Support As a free service to our customers we offer support in developing "rule-files" for automating corporate coding standards. If you have a coding standard that...
8
by: =?ISO-8859-1?Q?Arnaud_Carr=E9?= | last post by:
Hi all, I guess you all know how difficult it is to choose a conding standard. And even more difficult it is to explain the choice to your dev team :-) I'm looking for an "official" c++ coding...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.