Skip to content

Commit

Permalink
Guide update and removed the last warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
tpersson committed Apr 27, 2021
1 parent 4a9f513 commit fc4e4af
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 27 deletions.
15 changes: 15 additions & 0 deletions doc/latexuguide/control.tex
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,21 @@ \section{SELECT}
The \hyperref[chap:plot]{\texttt{PLOT}} command also accepts the new variable
in the table.

\section{Add2expr}
\label{sec:add2expr}
The \texttt{ADD2EXPR} command is used to add a variable to an already defined deferred expression.
\madbox{
ADD2EXPR, \=var=string, expr=string \\
}
An example of how it is used is given below.
\madbox{
a := b + c;
add2expr, var=a, expr=-d;
show, a;
a := b + c - d;
}


%% EOF


8 changes: 5 additions & 3 deletions doc/latexuguide/conventions.tex
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,8 @@ \subsection{Linear Lattice Functions (Optical Functions)}
variable.
Dispersive and chromatic functions are hence derivatives with
respect to PT.
And since PT=BETA*DELTAP, where BETA is the relativistic Lorentz
And since PT$\approx$BETA*DELTAP (see derivation in chapter~\ref{chap:pt_rel_dp}),
where BETA is the relativistic Lorentz
factor, those functions given by \madx must be multiplied by BETA a
number of time equal to the order of the derivative to find the
functions given in the literature.
Expand Down Expand Up @@ -664,7 +665,7 @@ \subsection{Chromatic Functions}
Notice also that in \madx, PT substitutes DELTAP as longitudinal
variable. Dispersive and chromatic functions are hence derivatives with
respect to PT.
Since PT=BETA/DELTAP, where BETA is the relativistic Lorentz
Since PT$\approx$BETA*DELTAP (see derivation in chapter~\ref{chap:pt_rel_dp}), where BETA is the relativistic Lorentz
factor, those functions given by \madx must be multiplied by BETA a
number of times equal to the order of the derivative to find the
functions given in the literature.
Expand Down Expand Up @@ -748,7 +749,8 @@ \subsection{Variables in the SUMM Table}
Notice that in \madx, PT substitutes DELTAP as longitudinal
variable. Dispersive and chromatic functions are hence derivatives with
respect to PT.
And since PT=BETA*DELTAP, where BETA is the relativistic Lorentz
And since PT$\approx$BETA*DELTAP (see derivation in chapter~\ref{chap:pt_rel_dp})
,where BETA is the relativistic Lorentz
factor, those functions given by \madx must be multiplied by BETA a
number of time equal to the order of the derivative to find the
functions given in the literature.
Expand Down
3 changes: 2 additions & 1 deletion doc/latexuguide/cororbit.tex
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ \section{CORRECT}
imported from an external file (with the \texttt{READTABLE} command), for
example to use measured BPM data. In that case, the imported twiss
table is allowed to contain coordinate data only at the location of
the monitors.
the monitors. Note that the list has to be in order and that you
cannot skip any locations of the monitors you have included.

\ttitem{NAME\_COL} The name of the column that contains the name of
monitors in the tables. (Default: "\texttt{name}")
Expand Down
2 changes: 2 additions & 0 deletions doc/latexuguide/pitfalls.tex
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,6 @@ \chapter{\madx recipes and pitfalls}

\end{description}



%EOF
4 changes: 3 additions & 1 deletion doc/latexuguide/uguide.tex
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
tfs, c6t, sxf, plot, index, rplot_index,
survey, twiss, match, emit, aperture, makethin, error, cororbit, sodd, touschek, ibs, thintrack,
ptc-general, ptc-track, ptc-twiss, ptc-normal, ptc-auxiliaries,
defects, pitfalls
defects, ptdp, pitfalls
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Expand Down Expand Up @@ -135,9 +135,11 @@ \part{\ptc Commands}
\part{Trailing Material}
\include{defects} % Known Differences to Other Programs
\include{pitfalls}
\include{ptdp}
\include{contributors}
\include{changelog}


\bibliographystyle{unsrt}
\bibliography{biblio-mad}

Expand Down
39 changes: 19 additions & 20 deletions src/mad_str.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ myatof(const char *instr){
return atof(instr);
}
void
mystrcpy(struct char_array* target, char* source)
mystrcpy(struct char_array* target, const char *source)
{
// LD: 2021.04.27, fixed bug, switch to strncpy to avoid warning
/* string copy to char_array with size adjustment */
int len = strlen(source);
while (len >= target->max) grow_char_array(target);
strncat((*target->c=0, target->c), source, len);
strncpy(target->c, source, len+1);
}

char*
Expand Down Expand Up @@ -65,33 +66,31 @@ mystrstr(char* string, const char* s)
}

void
myrepl(const char* in, const char* out, char* string_in, char* string_out)
myrepl(const char* in, const char* out, const char* restrict string_in, char* restrict string_out)
/* replaces all occurrences of "in" in string_in by "out"
in output string string_out */
{
int n, add, l_in = strlen(in), l_out = strlen(out);
char* cp;
char tmp[8];
while ((cp = strstr(string_in, in)) != NULL)
// LD: 2021.04.27, fixed bug, speed-up.
char tmp[16];

if (*out == '$') {
int n = get_variable(&out[1]);
sprintf(tmp, "%d", n); out = tmp;
}

int l_in = strlen(in), l_out = strlen(out);

for (char *cp; (cp=strstr(string_in, in)); )
{
while (string_in != cp) *string_out++ = *string_in++;
string_in += l_in;
if (*out == '$')
{
n = get_variable(&out[1]);
sprintf(tmp,"%d", n); add = strlen(tmp);
strncpy(string_out, tmp, add);
string_out += add;
}
else
{
strncpy(string_out, out, l_out);
string_out += l_out;
}
strncpy(string_out, out, l_out+1);
string_in += l_in;
string_out += l_out;
}
strcpy(string_out, string_in);
}


char*
mystrchr(char* string, char c)
/* returns strchr for character c, but only outside strings included
Expand Down
4 changes: 2 additions & 2 deletions src/mad_str.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ struct char_p_array;
double myatof(const char *instr);
char* mycpy(char* sout, const char* sin);
char* mystrchr(char* string, char c);
void mystrcpy(struct char_array* target, char* source);
void mystrcpy(struct char_array* target, const char *source);
char* mystrstr(char* string, const char* s);
void myrepl(const char* in, const char* out, char* string_in, char* string_out);
void myrepl(const char* in, const char* out, const char* string_in, char* string_out);
int mysplit(char* buf, struct char_p_array* list);

void conv_char(const char* string, struct int_array* tint);
Expand Down

0 comments on commit fc4e4af

Please sign in to comment.