PetaVision
Alpha
Main Page
Data Structures
weight_conversions.hpp
1
/*
2
* weight_conversions.hpp
3
*
4
* Created on: June 18, 2014
5
* Author: Craig Rasmussen
6
*/
7
8
#ifndef WEIGHT_CONVERSIONS_H_
9
#define WEIGHT_CONVERSIONS_H_
10
11
namespace
PV
{
12
14
static
inline
unsigned
char
compressWeight(
float
w,
float
minVal,
float
maxVal) {
15
return
(
unsigned
char
)(255.0f * ((w - minVal) / (maxVal - minVal)) + 0.5f);
16
}
17
19
static
inline
unsigned
char
compressWeight(
unsigned
char
w,
float
minVal,
float
maxVal) {
20
return
w;
21
}
22
24
static
inline
float
uncompressWeight(
unsigned
char
w,
float
minVal,
float
maxVal) {
25
return
(
float
)(minVal + (maxVal - minVal) * ((
float
)w / 255.0f));
26
}
27
29
static inline
float
uncompressWeight(
float
w,
float
minVal,
float
maxVal) {
return
w; }
30
31
}
// end namespace PV
32
33
#endif
/* WEIGHT_CONVERSIONS_H_ */
PV
Definition:
CheckpointableFileStream.cpp:3
OpenPV
src
connections
weight_conversions.hpp
Generated by
1.8.11