Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1993

[Date Index] [Thread Index] [Author Index]

Search the Archive

Question about parallel operations on lists

  • To: mathgroup at
  • Subject: Question about parallel operations on lists
  • From: buchanan at (Bob Buchanan)
  • Date: Tue, 19 Jan 93 10:27:03 EST

Calling all Mma gurus,

	I'm coding some simple numerical methods for PDE conservation
laws in one of my classes.  Does anyone know a way to clean up the
code of GodunovFlux[] (shown below) so that it doesn't require the
Do[] loops?

Flux[x_] := x	(* simple flux function *)

GodunovFlux[u_List,v_List] :=
		diff = Abs[u-v] /. x_ :> 0 /; x < 1/1000;
(* zero out any differences in u-v which are < 0.001 *)
		s = Table[0, {Length[u]}];
		fluxu = Flux[u]; fluxv = Flux[v];
		y = fluxv;
(* if u-v != 0 then compute approximation to derivative *)
		Do[s[[i]] = If[diff[[i]] > 0, 
				(fluxu[[i]] - fluxv[[i]])/(u[[i]] - v[[i]]),
(* if previous result > 0 then y <- fluxu *)
		Do[y[[i]] = If[s[[i]] > 0,fluxu[[i]],y[[i]]],

Basically, I'm looking for an elegant (or arcane) way to avoid doing so
much of this calculation element-wise.

Bob Buchanan	(Bob_Buchanan at

  • Prev by Date: Constructing distributions from data
  • Next by Date: contour graphics
  • Previous by thread: Constructing distributions from data
  • Next by thread: contour graphics