我必须标准化范围 [-1;1] 中的值列表。我在 c# 中找到了这段代码,但我不知道这种语言。有人可以帮我用 C++ 翻译这个吗?
List<int> list = new List<int>{-5,-4,-3,-2,-1,0,1,2,3,4,5};
double scaleMin = -1; //the normalized minimum desired
double scaleMax = 1; //the normalized maximum desired
double valueMax = list.Max();
double valueMin = list.Min();
double valueRange = valueMax - valueMin;
double scaleRange = scaleMax - scaleMin;
IEnumerable<double> normalized =
list.Select (i =>
((scaleRange * (i - valueMin))
/ valueRange)
+ scaleMin);