Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Total library rewrite #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions .autotest

This file was deleted.

27 changes: 26 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
*.gem
*.rbc
.bundle
.config
.yardoc
Gemfile.lock
InstalledFiles
_yardoc
coverage
doc/
lib/bundler/man
pkg
rdoc
spec/reports
test/tmp
test/version_tmp
tmp
*.bundle
*.so
*.o
*.a
mkmf.log
*~
coverage/*
pkg/*
*DS_Store
.rvmrc
.ruby-version
.ruby-gemset
4 changes: 2 additions & 2 deletions .rspec
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
--color
-f s
-b
--warnings
--require spec_helper
11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
script: rspec
language: ruby
notifications:
email: false
rvm:
- 1.9
- 2.0
- 2.1
before_install:
- sudo apt-get update -qq
- sudo apt-get install -y gsl-bin libgsl0-dev
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source 'https://rubygems.org'

# Specify your gem's dependencies in integration.gemspec
gemspec
3 changes: 0 additions & 3 deletions History.txt

This file was deleted.

47 changes: 6 additions & 41 deletions README.txt → LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,60 +1,25 @@
= integration
Copyright (c) 2005 Beng
2011 clbustos
2014 arrowcircle

* http://github.com/clbustos/integration

== DESCRIPTION:

Numerical integration for Ruby, with a simple interface

== FEATURES/PROBLEMS:

* Use only one method: Integration.integrate
* Rectangular, Trapezoidal, Simpson, Adaptive quadrature, Monte Carlo and Romberg integration methods available on pure Ruby.
* If available, uses Ruby/GSL QNG non-adaptive Gauss-Kronrod integration and QAG adaptive integration, with support for Infinity+ and Infinity-


== SYNOPSIS:

Integration.integrate(1,2,{:tolerance=>1e-10,:method=>:simpson}) {|x| x**2} => 2.333333

# Support for infinity bounds with GSL QAG adaptative integration

normal_pdf=lambda {|x| (1/Math.sqrt(2*Math::PI))*Math.exp(-(x**2/2))}
Integration.integrate(Integration::MInfinity, 0 , {:tolerance=>1e-10}, &normal_pdf) => 0.5
Integration.integrate(0, Integration::Infinity , {:tolerance=>1e-10}, &normal_pdf) => 0.5

== REQUIREMENTS:

* Ruby/GSL, for better performance and support for infinite bounds

== INSTALL:

gem install integration

== LICENSE:

Copyright (c) 2005 Beng
2011 clbustos

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE DEVELOPERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Except as contained in this notice, the name of the Beng shall not
be used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from Beng.

9 changes: 0 additions & 9 deletions Manifest.txt

This file was deleted.

56 changes: 56 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Integration

[![Build Status](https://travis-ci.org/arrowcircle/integration.svg?branch=master)](https://travis-ci.org/arrowcircle/integration)
Numerical integration for Ruby, with a simple interface

## Installation

Add gem `integration` to your Gemfile:

gem 'integration'

## Usage:

Integrate have only one method: `integrate`

Without GSL:

```
Integration.integrate(1, 2, {tolerance: 1e-10, method: :simpson}) { |x| x**2 }
=> 2.333333
```
With GSL (support for infinity bounds with GSL QAG adaptative integration):

```
func = ->(x) { (1/Math.sqrt(2 * Math::PI)) * Math.exp(-(x**2 / 2)) }

Integration.integrate(Integration::MInfinity, 0, {tolerance: 1e-10 }, &func)
=> 0.5

Integration.integrate(0, Integration::Infinity, {tolerance: 1e-10}, &func)
=> 0.5
```

## Available methods
Pure Ruby methods:

* Simpson (`:simpson`, default method)
* Rectangular (`:rectangular`)
* Trapezoidal (`:trapezoidal`)
* Adaptive quadrature (`:adaptive_quadrature`)
* Romberg (`:romberg`)
* Monte Carlo (`:monte_carlo`, bad results)

GSL methods:

* QNG (`:qng`)
* QAG (`:qag`)

## REQUIREMENTS:

Integration works only with Ruby 1.9+

Integration depends on GSL ( GNU Scientific Library ) for infinity bounds and faster algoritms support.

* For Mac OS X: `brew install gsl`
* For Ubuntu / Debian: `sudo apt-get install gsl`
27 changes: 1 addition & 26 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,27 +1,2 @@
# -*- ruby -*-
$:.unshift(File.expand_path(File.dirname(__FILE__)+"/lib/"))
require 'rubygems'
require 'hoe'
require 'integration'
require 'rubyforge'

# Hoe.plugin :compiler
# Hoe.plugin :gem_prelude_sucks
Hoe.plugin :git
# Hoe.plugin :inline
# Hoe.plugin :racc
# Hoe.plugin :rubyforge

Hoe.spec 'integration' do

self.developer('Ben Gimpert', 'NO_EMAIL')

self.developer('Claudio Bustos', 'clbustos_at_gmail.com')

self.version=Integration::VERSION
self.extra_dev_deps << ["rspec",">=2.0"] << ["rubyforge",">=0"]

end
# git log --pretty=format:"*%s[%cn]" v0.5.0..HEAD >> History.txt
# vim: syntax=ruby
require "bundler/gem_tasks"

27 changes: 27 additions & 0 deletions integration.gemspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'integration/version'

Gem::Specification.new do |spec|
spec.name = 'integration'
spec.version = IntegrationLib::VERSION
spec.authors = ['Ben Gimpert', 'Claudio Bustos', 'Oleg Bovykin']
spec.email = ['clbustos_at_gmail.com', 'oleg.bovykin@gmail.com']
spec.summary = %q{Integration methods, based on original work by Beng}
spec.description = %q{Numerical integration for Ruby, with a simple interface}
spec.homepage = ''
spec.license = 'MIT'

spec.files = `git ls-files -z`.split("\x0")
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ['lib']

spec.add_development_dependency 'bundler', '~> 1.6'
spec.add_development_dependency 'rake'
spec.add_development_dependency 'rspec'

spec.add_runtime_dependency 'rb-gsl'
spec.add_runtime_dependency 'activesupport'
end
Loading