예제 #1
0
Float calDiscreteErrorLinf(const arrayList &ao, const arrayList &ap) {
	assert(ao.size() == ap.size());
	int n = ao.size();
	arrayList aabs(n);
	for (int i = 0; i < n; i++) {
		aabs[i] = ABS(ap[i] - ao[i]);
	}
	return aabs.max();
}
예제 #2
0
Float calDiscreteErrorL1(const arrayList &ao, const arrayList &ap) {
	assert(ao.size() == ap.size());
	int n = ao.size();
	Float errsum = 0.0;
	for (int i = 0; i < n; i++) {
		errsum += abs(ap[i] - ao[i]);
	}
	return errsum;
}
예제 #3
0
Float cal_weighted_arithmetic_mean(const arrayList &a, const arrayList &w) {
	assert(a.size() == w.size());
	int len = a.size();
	double sumup = 0.0;
	double sumdown = 0.0;
	for (int i = 0; i < len; i++) {
		sumup += w[i] * a[i];
		sumdown += w[i];
	}
	return sumup / sumdown;
}
예제 #4
0
파일: arrayBuffer.cpp 프로젝트: jkells/nscp
/**
* Create an arrayBuffer from a list.
* This is the reverse of arrayBuffer2list.
* <b>Notice</b> it is up to the caller to free the memory allocated in the returned buffer.
*
* @param lst A list to convert.
* @param &argLen Write the length to this argument.
* @return A pointer that is managed by the caller.
*/
array_buffer::arrayBuffer array_buffer::list2arrayBuffer(const arrayList lst, unsigned int &argLen) {
	argLen = static_cast<unsigned int>(lst.size());
	arrayBuffer arrayBuffer = new arrayBufferItem[argLen];
	arrayList::const_iterator it = lst.begin();
	int i;
	for (i=0;it!=lst.end();++it,i++) {
		std::wstring::size_type alen = (*it).size();
		arrayBuffer[i] = new wchar_t[alen+2];
		wcsncpy(arrayBuffer[i], (*it).c_str(), alen+1);
	}
	if (i != argLen)
		throw ArrayBufferException("Invalid length!");
	return arrayBuffer;
}