Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] View of /branches/vis12/rtest/tests/heron/heron.diderot
ViewVC logotype

View of /branches/vis12/rtest/tests/heron/heron.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2718 - (download) (annotate)
Tue Sep 23 17:51:35 2014 UTC (4 years, 11 months ago) by jhr
File size: 644 byte(s)
  Added heron as a regression test (tests loading of sequences)
/*! \file heron.diderot
 *
 * \author John Reppy
 *
 * This example illustrates using Heron's method for computing square roots.  It
 * serves as a test for loading dynamic data sequences.
 */

/*
 * COPYRIGHT (c) 2012 The Diderot Project (http://diderot-language.cs.uchicago.edu)
 * All rights reserved.
 */

input int{} args = load("../../data/numbers.nrrd");
int nArgs = length(args);
real eps = 0.00001;

strand SqRoot (real arg)
{
    output real out = arg;  // holds root approximation

    update {
	out = (out + arg/out) / 2.0;
	if (|out^2 - arg| / arg < eps)
	    stabilize;
    }
}

initially { SqRoot(args{i}) | i in 0 .. nArgs-1 };

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0