H
Holgerson
Hi everybody,
here is an issue I just can't cope with: What I try to do is to
analyze a name (e.g. of an array or so) in order to search for numbers
within that name that give me an idea about that very array. It's
easiest explained with an example:
construct array: Mat_IO_DP array_temp_20; (I'm using
numerical recipes)
--> What I need now is to extract that "20" as a double number. If I
do that in the main code it's really no problem whatsoever:
#define STRING(s) #s
........................................
string matrix_string = STRING(array_temp_20);
string numbers ="0123456789";
int pos1 = matrix_string.find_last_of(numbers);
double last = double((int(matrix_string[pos1]) -
48)); //gives me the "0" from the "20" I look for
int pos2 = matrix_string.find_last_of(numbers, pos1 - 1);
double penultimate = double((int(matrix_string[pos2]) -
48)); //gives me the "2" from the "20" I look for
and so forth
Now what is my problem? ->
Naturally I try to perform that whole procedure using a function like
double temp = get_temp_from_name(array_temp_20);
Now the function prototype itself would look like
double get_temp_from_name(Mat_IO_DP matrix_name)
--> It turns out that the code in the function then really deals with
"matrix_name" rather than my argument "array_temp_20" that I actually
try to deliver. Now there is no number in "matrix_name", the thing
goes all wrong. Have you guys ever come across this? Thanks a lot for
any help,
Holger
here is an issue I just can't cope with: What I try to do is to
analyze a name (e.g. of an array or so) in order to search for numbers
within that name that give me an idea about that very array. It's
easiest explained with an example:
construct array: Mat_IO_DP array_temp_20; (I'm using
numerical recipes)
--> What I need now is to extract that "20" as a double number. If I
do that in the main code it's really no problem whatsoever:
#define STRING(s) #s
........................................
string matrix_string = STRING(array_temp_20);
string numbers ="0123456789";
int pos1 = matrix_string.find_last_of(numbers);
double last = double((int(matrix_string[pos1]) -
48)); //gives me the "0" from the "20" I look for
int pos2 = matrix_string.find_last_of(numbers, pos1 - 1);
double penultimate = double((int(matrix_string[pos2]) -
48)); //gives me the "2" from the "20" I look for
and so forth
Now what is my problem? ->
Naturally I try to perform that whole procedure using a function like
double temp = get_temp_from_name(array_temp_20);
Now the function prototype itself would look like
double get_temp_from_name(Mat_IO_DP matrix_name)
--> It turns out that the code in the function then really deals with
"matrix_name" rather than my argument "array_temp_20" that I actually
try to deliver. Now there is no number in "matrix_name", the thing
goes all wrong. Have you guys ever come across this? Thanks a lot for
any help,
Holger