-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSamplePoint.cpp
59 lines (40 loc) · 925 Bytes
/
SamplePoint.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include "stdafx.h"
#include "NeuralNet.h"
//SamplePoint::SamplePoint(const MyPoint &Point):MyPoint(Point){
// Weight=1.0;
//}
SamplePoint::SamplePoint(const MyPoint &Point, RealType InitWeight):MyPoint(Point){
Weight=InitWeight;
Classification=NULL;
Next=NULL;
}
SamplePoint::SamplePoint(){ //default constructor
Next=NULL;
Classification=NULL;
}
ostream& operator << ( ostream& os, SamplePoint &Pt ){
//first output the weight (if not 1.0)
if (Pt.Weight != 1.0)
os << "W " << Pt.Weight;
//then output the point
MyPoint TempPt;
TempPt=Pt;
os << TempPt;
return os;
}
istream& operator >> ( istream& is, SamplePoint &Pt ){
//first read the weight
char c;
RealType Weight;
is>>ws;
c=is.peek();
if (c=='W')
is >> c >> Weight; // read chracter and val
else
Weight=1.0;
//then read the point
MyPoint TempPt;
is >> TempPt;
Pt= static_cast <SamplePoint> (TempPt);
return is;
}