You are here: Foswiki>Sandbox Web>SandBoxPage (19 Oct 2013, MarioStorti)Edit Attach

FORTRAN

%CODE{ lang="fortran" num="10" numstep="2" }% subroutine doit(n,a,b,x,acpy,bcpy,ivpt) implicit real*8 (a-h,o-z)

integer ipvt(2*n) double precision a(2*n+1,2*n),b(2*n),x(2*n), * acpy(2*n+1,2*n),bcpy(2*n),ttot(3),t1 double precision time(8,6),cray,ops,total,norma,normx double precision resid,residn,eps,epslon lda = 2*n+1 c c this program was updated on 10/12/92 to correct a c problem with the random number generator. The previous c random number generator had a short period and produced c singular matrices occasionally. c cray = .056 ops = (2.0d0*dfloat(n)**3)/3.0d0 + 2.0d0*dfloat(n)**2 c call matgen(acpy,lda,n,bcpy,norma) c-> open(7,name='lb100dl.out') c-> do j=1,n c-> do i=1,n c-> write (7,*) acpy(i,j) c-> enddo c-> enddo c-> do i=1,n c-> write(7,*) bcpy(i) c-> enddo niter = 200*100**3/n**3 if (niter.lt.5) niter=5 write(,) 'niter: ', niter do icptim=1,3 t1 = gettod() do k=1,niter do jcp=icptim,1,-1 do kk=1,n do ll=1,n a(kk,ll) = k*jcp*acpy(kk,ll) enddo b(kk)=k*jcp*bcpy(kk) enddo enddo call dgefa(a,lda,n,ipvt,info) if (info.ne.0) then write(,) 'On iter ',k,' dgefa returned info= ',info stop endif call dgesl(a,lda,n,ipvt,b,0) enddo ttot(icptim)=gettod()-t1 write(,) 'On iter ',icptim,' ttot: ',ttot(icptim) enddo t0 = 2*ttot(1)-ttot(2) t0_3 = 1.5*ttot(1)-0.5*ttot(3) dev = abs(t0_3-t0)/t0 if (dev.gt.0.1) then write(,) 'warning: max dev. exceeded: t0= ',t0,' t0_3= ', * t0_3,' relative dev= ',dev endif flopsrate = niter*ops/(1e6*t0) write(,) 'Elapsed: ',t0,' per iter: ',t0/niter, * ' rate: ',flopsrate,' [mflops]' c Verify amaxerr=0. do k=1,n err = abs(b(k)-1.) if (err.gt.amaxerr) amaxerr = err enddo if (amaxerr.gt.1e-10) write (,) 'warning: max err: ', amaxerr write (,) 'n, flops ', n, flopsrate c-> do i=1,n c-> write (7,*) b(i) c-> enddo c-> close(7) end %ENDCODE%

C++

%CODE{ lang="cpp" num="10" numstep="2" }% //---:---<*>---:---<*>---:---<*>---:---<*>---:---<*> void scale(vector &x,double c) { int N = x.size(); for (int j=0; j<N; j++) x[j] *= c; }

typedef double (*map_fun_t)(double x,void *data);

//---:---<*>---:---<*>---:---<*>---:---<*>---:---<*> void apply(vector &x,map_fun_t fun, void *data=NULL) { int N = x.size(); for (int j=0; j<N; j++) x[j] = fun(x[j],data); }

//---:---<*>---:---<*>---:---<*>---:---<*>---:---<*> void vecset(vector &x,double c) { int N = x.size(); for (int j=0; j<N; j++) x[j] = c; }

//---:---<*>---:---<*>---:---<*>---:---<*>---:---<*> double dot(vector &y,vector &x) { unsigned int N = x.size(); ASSERT(y.size()==N); double d = 0.0; for (unsigned int j=0; j<N; j++) d += y[j]*x[j]; return d; }

//---:---<*>---:---<*>---:---<*>---:---<*>---:---<*> double norm(vector &x) { return sqrt(dot(x,x)); } %ENDCODE%

Scheme

%CODE{ lang="scheme" num="1" }% (define (log-file file msg . args) ;; (cond ((string? file) ;; (let ((port (open-file file "a"))) ;; (format port "~a: ~a\n" (ftime) ;; (apply format #f msg args)) ;; (close port))) (cond ((string? file) (with-output-to-file-append file (lambda () (format #t "~a: ~a\n" (ftime) (apply format #f msg args))))) ((port? file) (format file "~a: ~a\n" (ftime) (apply format #f msg args))))) %ENDCODE%

Ejemplo de tabla

Table with two Header Rows and Footer Row
Num Status Action Who When Progress
Num Status Action Who When Progress
1 C Chose new colours John 1-Dec-02  
2 X Release John 1-Apr-02  
3   Get feedback Anne 1-Feb-02  
12 C Spec error handling Jack 1-Dec-02  
5   Abc John    

-- MarioStorti - 2009-12-26

Warning
This site does not allow %INCLUDE% of URLs
.
Topic revision: r9 - 19 Oct 2013, MarioStorti
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback