Rev | Line | |
---|
[430] | 1 | #include "madx.h" |
---|
| 2 | |
---|
| 3 | double |
---|
| 4 | mult_par(const char* par, struct element* el) |
---|
| 5 | /* returns multipole parameter for par = "k0l" or "k0sl" etc. */ |
---|
| 6 | { |
---|
| 7 | double val = zero; |
---|
| 8 | char tmp[12] ,*p; |
---|
| 9 | strcpy(tmp, par); |
---|
| 10 | if (*tmp == 'k' && (p = strchr(tmp, 'l')) != NULL) |
---|
| 11 | { |
---|
| 12 | *p = '\0'; /* suppress trailing l */ |
---|
| 13 | int skew = 0; |
---|
| 14 | if ((p = strchr(tmp, 's')) != NULL) |
---|
| 15 | { |
---|
| 16 | skew = 1; *p = '\0'; |
---|
| 17 | } |
---|
| 18 | int k = 0; |
---|
| 19 | sscanf(&tmp[1], "%d", &k); |
---|
| 20 | double vect[FIELD_MAX]; |
---|
| 21 | int l; |
---|
| 22 | if (skew) l = element_vector(el, "ksl", vect); |
---|
| 23 | else l = element_vector(el, "knl", vect); |
---|
| 24 | if (k < l) val = vect[k]; |
---|
| 25 | } |
---|
| 26 | return val; |
---|
| 27 | } |
---|
| 28 | |
---|
| 29 | |
---|
Note: See
TracBrowser
for help on using the repository browser.