Re: setting precision locally within module
- To: mathgroup at smc.vnet.net
- Subject: [mg72460] Re: [mg72447] setting precision locally within module
- From: "Chris Chiasson" <chris at chiasson.name>
- Date: Fri, 29 Dec 2006 05:15:47 -0500 (EST)
- References: <200612281011.FAA04465@smc.vnet.net>
If you read the description of $Pre closely, you will probably notice that it only applies to input. By the time your gauss function is called (and Sets $Pre$nnn, which won't change $Pre anyway), it is too late for $Pre to do anything. It appears you are trying to write a pivoting operation for Gaussian elimination. Why do you need to set the precision in the middle of your pivoting routine? Can you just write the logic for the routine and then supply it with numbers of the desired precision? Are you concerned about formatting output? If that's the case, you can easily do your computations and then specify the precision to which you would like the numbers printed by using NumberForm or by directly changing the precision of the numbers after the computation is finished through the use of SetPrecision. On 12/28/06, jltrahan at mail.usf.edu <jltrahan at mail.usf.edu> wrote: > Hello, > I'm trying to define the number of significant figures used for all > calculations within a module. For example, I'm using the following syntax: > > gauss[dig_]:=Module[{$Pre=N[#,dig]&}, > For[k=1,k<=n,k++, > For[i=k+1,i<=n,i++,multiplier=A[[i,k]]/A[[k,k]]]]; > ...] > > I must be able to input any number of digits specified. I'd really > appreciate any help. > Thanks in advance, > Jamie > > -- http://chris.chiasson.name/
- References:
- setting precision locally within module
- From: jltrahan@mail.usf.edu
- setting precision locally within module