Hi all,
I am using Borland C++ 4.5 on 32-bit windows machine. I am getting "exp: OVERFLOW error" for my code. can anybody tell me how to deal with it.
I am not posting my
Code:
struct MATRIX {
int rows;
int cols;
double **t;
};
...
...
double norm(struct MATRIX t, double s){...}
\\returns s-norm
double scalar(struct MATRIX t){...}
\\returns the only element for 1X1 matrix
struct MATRIX ind_response(struct MATRIX t, int index){...}
\\returns a structure containing a column matrix having t.cols number of rows
struct MATRIX multifun(struct MATRIX a, struct MATRIX b, char ch)
\\return multiplied value of a.t and b.t matrices when ch == '*'
struct MATRIX transpose(struct MATRIX t)
\\returns transpose of matrix
double fun(struct MATRIX x, struct MATRIX y, struct MATRIX z, int l){
double fval, sum = 0;
float bx, ybx;
int i;
for(i = 0; i < y.rows; i++){
bx = scalar(multifun(transpose(z), ind_response(x, i), '*'));
ybx = *(*(y.t+i)+0)* bx;
sum = sum - (ybx - log(1 + exp(bx)));
}
fval = sum + l* norm(z, 2.0);
return fval;
}
...
main(){
...
}