~ubuntu-branches/ubuntu/oneiric/ctioga2/oneiric

« back to all changes in this revision

Viewing changes to tests/generate-data.rb

  • Committer: Bazaar Package Importer
  • Author(s): Vincent Fourmond
  • Date: 2011-01-24 21:36:06 UTC
  • Revision ID: james.westby@ubuntu.com-20110124213606-9ettx0ugl83z0bzp
Tags: upstream-0.1
ImportĀ upstreamĀ versionĀ 0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright 2010 by Vincent Fourmond
 
2
#
 
3
# This small script generates the data files used for ctioga2's tests
 
4
# based on reading data files.
 
5
#
 
6
# This file can be distributed under the same terms as ctioga2 itself.
 
7
 
 
8
File.open("3d-data.dat",'w') do |f|
 
9
  nb = 51
 
10
  nb.times do |i|
 
11
    x = 3 * (i - nb/2)/(nb/2 * 1.0)
 
12
    nb.times do |j|
 
13
      y = 3 * (j - nb/2)/(nb/2 * 1.0)
 
14
      f.puts "#{x}\t#{y}\t#{(x**2 + y**2) * Math.exp(-x**2 - y**2)}"
 
15
    end
 
16
  end
 
17
end