Skip to content
Snippets Groups Projects
Commit a2b4257d authored by Chris Sangwin's avatar Chris Sangwin
Browse files

Workaround to issue #1129. TODO: error trapping in user contributed functions.

parent b4136712
Branches
No related tags found
No related merge requests found
......@@ -24,7 +24,7 @@
/* Calculate the divergence of a vector-valued function */
/****************************************************************/
div(u, vars):= block([div_vec],
if not(listp(vars)) or emptyp(vars) then error("div: the second argument must be a list of variables."),
/* TODO: error trapping: if not(listp(vars)) or emptyp(vars) then error("div: the second argument must be a list of variables."), */
if matrixp(u) then funcs: list_matrix_entries(u) else funcs: flatten(u),
/* TODO: confirm div should always simplify? */
div_vec: map(lambda([ex], ev(diff(funcs[ex],vars[ex]), simp)), ev(makelist(ii,ii,1,length(vars)), simp)),
......@@ -39,7 +39,7 @@ s_test_case(div(matrix([x^2*cos(y),y^3]),[x,y]), 2*x*cos(y)+3*y^2);
/* Calculate the curl of a vector-valued function */
/****************************************************************/
curl(u,vars):= block([cux, cuy, cuz],
if not(listp(vars)) or emptyp(vars) then error("curl: the second argument must be a list of 3 variables."),
/* TODO: error trapping: if not(listp(vars)) or emptyp(vars) then error("curl: the second argument must be a list of 3 variables."), */
if matrixp(u) then [ux,uy,uz]: list_matrix_entries(u) else [ux,uy,uz]: flatten(u),
cux: diff(uz,vars[2]) - diff(uy,vars[3]),
cuy: diff(ux,vars[3]) - diff(uz,vars[1]),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment