|
Hi there.
I am working on a project wich requires me to use matrices and do some computations on them. So I downloaded the LINPACK linear algebra library from
http://www.csit.fsu.edu/~burkardt/cpp_src/linpack/linpack.html
The library is very nice, offering a huge collection of very usefull matrix arithmetic.
I downloaded the source for the library which consisted of 2 .h files and 2 .c files. And when I try to compile the c files, using Visual Studio C++ 2003, I get two build errors:
linpack.c
c:\Documents Of I\UP\Year5 Semester2\EPR400\My Programming\TestMatrix\linpack.C(5668) : fatal error C1010: unexpected end of file while looking for precompiled header directive
blas1.c
c:\Documents Of I\UP\Year5 Semester2\EPR400\My Programming\TestMatrix\blas1.C(4532) : fatal error C1010: unexpected end of file while looking for precompiled header directive
So I need help to get the source code to compile on VS C++ 2003. I think I need to change settings for the precompiled headers section of the project properties but I dont have a clue what it all means.
Please help!
Thanks!
Ben
|
|
|
|
|
add to your c files #include "stdafx.h" if u are using then into a visual c++ project with precompiled header project option
NG
|
|
|
|
|
Or you could just edit your project properties to not include precompiled headers.
|
|
|
|
|
Hi.
Including the "stdafx.h" file in all the source files worked.
I couldn't turn of the Use Precompiled Headers option because the other source files in my project did indeed already include "stadafx.h".
Thanx for the help guys!!
|
|
|
|
|
I'm having trouble trying to do one on the implementation files of my project. can you plz help... i will attach the appropriate header file/s and .cpp files which I have completed, yet however that is one .cpp which is partially completed, can you really help with the definition of the member functions. The partially completed file is called EmployeeDatabase_template[1].cpp. i included the source code below for you to look at. plz help with definition of these member functions
#include "EmployeeDatabase.h"
#include
using namespace std;
EmployeeDatabase::EmployeeDatabase()
{ // Complete code.
people = 0; // The database is a vector of Persons.
size = 0; // The number of Persons in the database.
}
void EmployeeDatabase::getEids(vector &ids)
{ // Complete code.
}
string EmployeeDatabase::getName(int employeeID)
{// Complete code.
}
double EmployeeDatabase::getShoeSize(int employeeID)
{// Complete code.
}
void EmployeeDatabase::makePerson(string employeeName, int employeeID, double employeeShoeSize)
{//complete code.
}
int EmployeeDatabase::getSize()
{// Complete code.
return size;
}
here is the appropriate specification files(header files).
this is EmployeeDatabase.h
// A EmployeeDatabase consists of a vector of Persons;
// methods are supplied to retrieve all the employee IDs and
// to query the database for employee names and shoesizes using
// the corresponding employee id.
#include "Person.h"
#include
using namespace std;
#ifndef EmployeeDatabase_H
#define EmployeeDatabase_H
class EmployeeDatabase{
public:
EmployeeDatabase();
// Constructor:
// Makes an instance of an EmployeeDatabase containing no data.
void getEids(vector & ids);
// Returns a vector of all the employee ids in the vector people.
string getName(int employeeID);
// Returns the name of the Person with eid equal to employeeID.
double getShoeSize(int employeeID);
// Returns the shoesize of the Person with eid equal to employeeID.
void makePerson(string employeeName, int employeeID, double employeeShoeSize);
// Creates a new instance of Person using the input data
// and adds it to the vector people.
int getSize();
// Returns the number of Persons stored.
private:
vector people; // The database is a vector of Persons.
int size; // The number of Persons in the database.
};
#endif //EmployeeDatabase_H
This is Person.h
// A Person consists of the name, the employee ID and the shoe size.
// Methods are supplied to retrieve each of the three data items.
using namespace std;
#include
#ifndef Person_H
#define Person_H
class Person{
public:
Person(); // Default constructor.
Person(string personName, int personId, double personShoeSize);
// Constructor:
// Makes an instance of a person with the
// given data.
string getName();
// Returns the name of the Person.
int getEid();
// Returns the employer ID of the Person.
double getShoeSize();
// Returns the shoesize of the Person.
private:
string name; // The employee's name.
int eid; // The employee's ID.
double shoeSize; // The employee's shoesize.
};
#endif
PLZ WITH THE FIRST BIT OF CODE THE OTHER TWO ARE THE HEADER FILES. I JUST CANT FIGURE OUT HOW TO DEFINE SOME OF THEM.
|
|
|
|
|
hi,
i have one request if you want some help :
please edit.Modify your message and put the codes into <pre></pre> tags for us to see the indentations, and the blocs of code correctly. you could separate the files using several tag blocs.
one more thing :
use the < and > buttons at the bottom of the edit box to let us see the template parameters... (we do not see the vectors and so...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
ok. no worries, thanks for the swift reply.
I'm having trouble trying to do one on the implementation files of my project. can you plz help... i will attach the appropriate header file/s and .cpp files which I have completed, yet however that is one .cpp which is partially completed, can you really help with the definition of the member functions. The partially completed file is called EmployeeDatabase_template.cpp. i included the source code below for you to look at. plz help with definition of these member functions
<pre>
#include "EmployeeDatabase.h"
#include <vector>
using namespace std;
EmployeeDatabase::EmployeeDatabase()
{ // Complete code.
size = 0;
}
void EmployeeDatabase::getEids(vector <int>&ids)
{ // Complete code.
}
string EmployeeDatabase::getName(int employeeID)
{// Complete code.
}
double EmployeeDatabase::getShoeSize(int employeeID)
{// Complete code.
}
void EmployeeDatabase::makePerson(string employeeName, int employeeID, double employeeShoeSize)
{//complete code.
}
int EmployeeDatabase::getSize()
{// Complete code.
return size;
}
</pre>
here is the appropriate specification files(header files).
this is EmployeeDatabase.h
<pre>
// A EmployeeDatabase consists of a vector of Persons;
// methods are supplied to retrieve all the employee IDs and
// to query the database for employee names and shoesizes using
// the corresponding employee id.
#include "Person.h"
#include <vector>
using namespace std;
#ifndef EmployeeDatabase_H
#define EmployeeDatabase_H
class EmployeeDatabase{
public:
EmployeeDatabase();
// Constructor:
// Makes an instance of an EmployeeDatabase containing no data.
void getEids(vector <int>& ids);
// Returns a vector of all the employee ids in the vector people.
string getName(int employeeID);
// Returns the name of the Person with eid equal to employeeID.
double getShoeSize(int employeeID);
// Returns the shoesize of the Person with eid equal to employeeID.
void makePerson(string employeeName, int employeeID, double employeeShoeSize);
// Creates a new instance of Person using the input data
// and adds it to the vector people.
int getSize();
// Returns the number of Persons stored.
private:
// The database is vector of Persons.
vector <Person> people;
int size; // The number of Persons in the database.
};
#endif //EmployeeDatabase_H
</pre>
This is Person.h
<pre>
// A Person consists of the name, the employee ID and the shoe size.
// Methods are supplied to retrieve each of the three data items.
using namespace std;
#include<string>
#ifndef Person_H
#define Person_H
class Person{
public:
Person(); // Default constructor.
Person(string personName, int personId, double personShoeSize);
// Constructor:
// Makes an instance of a person with the
// given data.
string getName();
// Returns the name of the Person.
int getEid();
// Returns the employer ID of the Person.
double getShoeSize();
// Returns the shoesize of the Person.
private:
string name; // The employee's name.
int eid; // The employee's ID.
double shoeSize; // The employee's shoesize.
};
#endif
</pre>
PLZ CAN YOU HELP ME WITH THE FIRST BIT OF CODE THE OTHER TWO ARE THE HEADER FILES. I JUST CANT FIGURE OUT HOW TO DEFINE SOME OF THE MEMBER FUNCTIONS.
-- modified at 23:40 Monday 5th September, 2005
|
|
|
|
|
class A
{
int i;
public:
A(int ii):i(ii){}
int operator ++()
{
return ++i;
}
int operator ++(int)
{
int ntemp;
ntemp = i;
++i;
return ntemp;
}
int geti(){return i;}
};
int main()
{
A a(2);
cout << a++ << endl
<< a.geti() << endl;
getchar();
}
Why the result is "2, 2" instead of "2, 3". a++ seems doesn't operate on A::i?
|
|
|
|
|
and what does cout << ++a << endl << a.geti() << endl; return ???
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
toxcct wrote:
and what does cout << ++a << endl << a.geti() << endl; return ???
This statement doesn't return anything, I think!
|
|
|
|
|
you think ? or you tested ?
in C++, postfixed ++ operator returns the value before the incrementation, while prefixed return the new value...
so, i ask you the question : what is the change when you switch the postfixed incrementation operation with the prefixed one ???
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
toxcct wrote:
in C++, postfixed ++ operator returns the value before the incrementation, while prefixed return the new value...
I implemented the operation as postfixed ++ operator supposed to be: first return the operand before any modification and then imcrement it.
int operator ++(int)
{
int ntemp;
ntemp = i;
++i;
return ntemp;
}
But I wonder why the
int geti(){return i;}
seems reading another object?That is my question.
toxcct wrote:
what is the change when you switch the postfixed incrementation operation with the prefixed one ???
int operator ++(int)
{
int ntemp;
ntemp = i;
++i;
return ntemp;
}
Do you mean the operation in bold?If so, I just wanted next time when "i" get referenced, it got incremented!
|
|
|
|
|
no no no, i talk about the line i quoted in my first answer.
your post/pre-fixed ++ operators are well written for both goals, but i wonder what would happen if, instead of calling a++ , you were calling ++a .
you wrote :
cout << a++ << endl << a.geti() << endl;
equivalent to :
cout << a.operator++(1) << endl << a.geti() << endl;
Now, i suggest writing instead :
cout << ++a << endl << a.geti() << endl;
equivalent to :
cout << a.operator++() << endl << a.geti() << endl;
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
sorry toxcct I don't see you point!
toxcct wrote:
you wrote :
cout << a++ << endl << a.geti() << endl; equivalent to : cout << a.operator++() << endl << a.geti() << endl;
This is postfixed version, and a.operator++()shoud be in prefixed version.
toxcct wrote:
Now, i suggest writing instead :
cout << ++a << endl << a.geti() << endl; equivalent to : cout << a.operator++(1) << endl << a.geti() << endl;
This is prefixed version, and a.operator++(1) shoud be in postfixed version!
Finally I figured out why the result is incorrect:
in
cout << ++a << endl << a.geti() << endl;
The A::geti() gets called first that was before "i" get incremented
cout << ++a << endl ; cout << a.geti() << endl;
will produce the right result!But what exactly happened?
|
|
|
|
|
tss,
you finnally did what i told you from at the beginning...
what happened is that geti() got the value returned by postfixed ++ operator, that means, the old value, just because you were on the same instruction !!!
ps: sorry for the mix i made in my mind between operator++() and operator++(int). you are right
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
actually, prefix operator is not correct because it should return an l-value (e.g. int& instead of int). however, this implementation is not very logical, because increment operator should not return different type that the one where it is defined.
|
|
|
|
|
Zdeslav Vojkovic wrote:
actually, prefix operator is not correct because it should return an l-value (e.g. int& instead of int).
What do you mean by that?
Zdeslav Vojkovic wrote:
however, this implementation is not very logical, because increment operator should not return different type that the one where it is defined.
The implementation should look like:
A operator ++()<br> {<br> return A(++i); <br> }
?
|
|
|
|
|
Zdeslav Vojkovic wrote: actually, prefix operator is not correct because it should return an l-value (e.g. int& instead of int).
What do you mean by that?
Zdeslav Vojkovic wrote: however, this implementation is not very logical, because increment operator should not return different type that the one where it is defined.
The implementation should look like:
A operator ++()<br> {<br> return A(++i); <br> } ?
|
|
|
|
|
it should look like this:
A& operator ++()<br />
{<br />
++i; <br />
return *this;<br />
}
|
|
|
|
|
if you have a function which receives 2 parameters:
fn(a, b)
when you call it, parameters are evaluated from right to left and put on stack, so if you call:
fn( fn1(), fn2());
fn2 will be evaluated FIRST, and result put on stack. now, fn1 will be evaluated and put on stack, so
when fn() starts to execute, it will find first parameter (result of fn1) on the top of the stack, and second parameter right after it.
similar works for expression 'cout << a << b;'
it is iterpreted as
( cout.operator <<(a) ) .operator <<(b);
so when it is called, first expression 'b' is evaluated and then 'a'. after this, operator << is called twice. in your case, this means that 'a.geti()' is executed before 'a++'. even if you write '++a' you won't get the expected result.
|
|
|
|
|
Zdeslav Vojkovic wrote:
fn( fn1(), fn2());
I'm pretty clear with that!
But not with
Zdeslav Vojkovic wrote:
similar works for expression 'cout << a << b;'
'cout << a << b;' to me is like a two times function calls each with a single argument, eg.
(cout::operator<<(a))
and
(cout::operator<<(a)).operator<<(b)
what decide their calling sequence?
|
|
|
|
|
hey all ...im kinda new to this place .....so dunno whether im posting in the right place .....
I have to complete this thing in a span of 3 days ..i dunno how ...but here goes ...
Take a Jpeg image and convert it to text ...
Can i get som ekind of algorithm for this purpose...or even a JPEG image file format ?? Or even links to those ....
The links that i have tried .....give me the details as to how a JPEG image is made .... not how the file is arranged ..
Can someone guide me in this respect .....
Thanks ,
Jomy
|
|
|
|
|
Jomy John wrote:
I have to complete this thing in a span of 3 days
Jomy John wrote:
Take a Jpeg image and convert it to text ...
You want to write an OCR program in 3 days ?
Jomy John wrote:
Can i get som ekind of algorithm for this purpose...or even a JPEG image file format ?? Or even links to those ....
GDI+ will let you read/write JPEGs in C++, and even gives you elegant access to the bits of the image. There's no text inside a JPEG though, you need to examine the individual bits and work out for yourself which bits are letters.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
thanks a lot .....
I have finished reading a Jpeg file ...using the File format of Jpeg ....and have the charcters in hex ....
Now ...are there any hex encoding tables..or sum rule by which i can encode my hex set of numbers to a Sms character set ???
|
|
|
|
|
OK, so you want to turn it into a string in order to transmit it ? Here[^] is some info on BASE64 encoding.
Christian Graus - Microsoft MVP - C++
|
|
|
|