【发布时间】:2016-03-11 12:47:40
【问题描述】:
我有两种方法来实现命名:Compute_correlation 和 cca。这就是我定义它们的方式:
namespace dlib
{
template <typename T>matrix<typename T::type,0,1> compute_correlations (
const matrix_exp<T>& L,
const matrix_exp<T>& R
);
template <typename T>matrix<T,0,1> cca (
const matrix<T>& L,
const matrix<T>& R,
matrix<T>& Ltrans,
matrix<T>& Rtrans,
unsigned long num_correlations,
unsigned long extra_rank = 5,
unsigned long q = 2,
double regularization = 0
);
int _tmain(int argc, _TCHAR* argv[]) {...}
template <
typename T
>
matrix<typename T::type,0,1> compute_correlations (
const matrix_exp<T>& L,
const matrix_exp<T>& R
)
{
DLIB_ASSERT( L.size() > 0 && R.size() > 0 && L.nr() == R.nr(),
"\t matrix compute_correlations()"
<< "\n\t Invalid inputs were given to this function."
<< "\n\t L.size(): " << L.size()
<< "\n\t R.size(): " << R.size()
<< "\n\t L.nr(): " << L.nr()
<< "\n\t R.nr(): " << R.nr()
);
typedef typename T::type type;
matrix<type> A, B, C;
A = diag(trans(R)*L);
B = sqrt(diag(trans(L)*L));
C = sqrt(diag(trans(R)*R));
A = pointwise_multiply(A , reciprocal(pointwise_multiply(B,C)));
return A;
}
template <typename T>
matrix<T,0,1> cca (
const matrix<T>& L,
const matrix<T>& R,
matrix<T>& Ltrans,
matrix<T>& Rtrans,
unsigned long num_correlations,
unsigned long extra_rank = 5,
unsigned long q = 2,
double regularization = 0
)
{
DLIB_ASSERT( num_correlations > 0 && L.size() > 0 && R.size() > 0 && L.nr() == R.nr() &&
regularization >= 0,
"\t matrix cca()"
<< "\n\t Invalid inputs were given to this function."
<< "\n\t num_correlations: " << num_correlations
<< "\n\t regularization: " << regularization
<< "\n\t L.size(): " << L.size()
<< "\n\t R.size(): " << R.size()
<< "\n\t L.nr(): " << L.nr()
<< "\n\t R.nr(): " << R.nr()
);
using std::min;
const unsigned long n = min(num_correlations, (unsigned long)min(R.nr(),min(L.nc(), R.nc())));
return impl_cca(L,R,Ltrans, Rtrans, num_correlations, extra_rank, q, n, regularization);
}
我正在尝试从 main 实现它们,但显示以下错误: 重新定义默认参数。请帮帮我
【问题讨论】:
-
出现错误是因为你试图重新定义默认参数,不要这样做,错误就会消失
-
不定义会报错
-
你得到什么错误?
标签: c++