stat_c 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6f63ee4a4e26bb9031d4eed9ea02cf02b63fb629
4
+ data.tar.gz: 4cb7709b9c16ddff13113495d0758533b6e96ec3
5
+ SHA512:
6
+ metadata.gz: b2fe2a4aed50969143e634271e133e3459dc51390c45ee983372a818b46e388e6c4c8b34752c24ebcf832c1cc9606c841caeec32a189a6d92ce82ddfd8763f46
7
+ data.tar.gz: aa2763572a0a0111ac0a6a2c451573aee9432e6c1f2115b7e428be055f33c21f15b7b1c5bef843596003ded7fb201082651e68f94488e4ad6ec1bebcddd9f7bb
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ lib/stat_c/stat_c.bundle
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ stat_c
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-2.3.1
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.3
4
+ - 2.2.4
5
+ - 2.3.0
6
+ - 2.3.1
7
+ before_install: gem install bundler -v 1.11.2
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at moorer@udel.edu. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in stat_c.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # StatC
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/stat_c`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'stat_c'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install stat_c
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/mooreryan/stat_c. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
data/Rakefile ADDED
@@ -0,0 +1,15 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+ require "rake/extensiontask"
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task :default => :spec
8
+
9
+ Rake::ExtensionTask.new do |ext|
10
+ ext.name = "stat_c"
11
+ ext.ext_dir = "ext/stat_c"
12
+ ext.lib_dir = "lib/stat_c"
13
+ end
14
+
15
+ Rake::Task[:spec].prerequisites << :compile
@@ -0,0 +1,18 @@
1
+ require "stat_c"
2
+ require "benchmark"
3
+
4
+ def mean ary
5
+ ary.reduce(:+) / ary.length.to_f
6
+ end
7
+
8
+ ary = (1..1_000_000).map(&:itself)
9
+
10
+ Benchmark.bmbm do |x|
11
+ x.report("ruby mean") do
12
+ mean ary
13
+ end
14
+
15
+ x.report("c mean") do
16
+ StatC::Array.mean ary
17
+ end
18
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "stat_c"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,3 @@
1
+ require "mkmf"
2
+
3
+ create_makefile "stat_c/stat_c"
@@ -0,0 +1,89 @@
1
+ /*********************************************************************
2
+
3
+ Copyright 2016 Ryan Moore
4
+ Contact: moorer@udel.edu
5
+
6
+ This file is part of StatC.
7
+
8
+ StatC is free software: you can redistribute it and/or modify it under
9
+ the terms of the GNU General Public License as published by the Free
10
+ Software Foundation, either version 3 of the License, or (at your
11
+ option) any later version.
12
+
13
+ StatC is distributed in the hope that it will be useful, but WITHOUT
14
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16
+ for more details.
17
+
18
+ You should have received a copy of the GNU General Public License
19
+ along with StatC. If not, see <http://www.gnu.org/licenses/>.
20
+
21
+ *********************************************************************/
22
+
23
+ #include <ruby.h>
24
+
25
+ /* classes and modules */
26
+ VALUE sc_mStatC;
27
+ VALUE sc_mArray;
28
+ VALUE sc_mError;
29
+ VALUE sc_eError;
30
+
31
+ static VALUE sc_mean(VALUE self, VALUE ary)
32
+ {
33
+
34
+ unsigned long i = 0;
35
+ long double sum = 0;
36
+ size_t len = RARRAY_LEN(ary);
37
+
38
+ if (len <= 0) {
39
+ rb_raise(sc_eError, "Array cannot be empty");
40
+ }
41
+
42
+ for (i = 0; i < len; ++i) {
43
+ sum += NUM2DBL(rb_ary_entry(ary, i));
44
+ }
45
+
46
+ return DBL2NUM(sum / len);
47
+ }
48
+
49
+ /* static VALUE var(VALUE self, VALUE ary) */
50
+ /* { */
51
+
52
+ /* } */
53
+
54
+ /* static VALUE var(int argc, VALUE* argv, VALUE self) */
55
+ /* { */
56
+ /* VALUE ary, sample; */
57
+
58
+ /* /\* one required and one optional argument *\/ */
59
+ /* rb_scan_args(argc, argv, "11", &ary, &sample); */
60
+
61
+ /* /\* if sample wasn't specified, set it to true *\/ */
62
+ /* if (NIL_P(sample)) { sample = 1; } */
63
+ /* } */
64
+
65
+ /* static VALUE var(int argc, VALUE* argv, VALUE self) */
66
+ /* { */
67
+ /* VALUE ary, sample; */
68
+
69
+ /* /\* one required and one optional argument *\/ */
70
+ /* rb_scan_args(argc, argv, "11", &ary, &sample); */
71
+
72
+ /* /\* if sample wasn't specified, set it to true *\/ */
73
+ /* if (NIL_P(sample)) { sample = 1; } */
74
+ /* } */
75
+
76
+ void Init_stat_c(void)
77
+ {
78
+ sc_mStatC = rb_define_module("StatC");
79
+
80
+ sc_mArray = rb_define_module_under(sc_mStatC, "Array");
81
+ sc_mError = rb_define_module_under(sc_mStatC, "Error");
82
+
83
+ sc_eError = rb_define_class_under(sc_mError, "Error", rb_eStandardError);
84
+
85
+ rb_define_singleton_method(sc_mArray, "mean", sc_mean, 1);
86
+ /* rb_define_singleton_method(mArray, "var", var, 1); */
87
+ /* rb_define_singleton_method(mArray, "sd", sd, -1); */
88
+ /* rb_define_singleton_method(mArray, "se", se, -1); */
89
+ }
@@ -0,0 +1,27 @@
1
+ # Copyright 2016 Ryan Moore
2
+ # Contact: moorer@udel.edu
3
+ #
4
+ # This file is part of StatC.
5
+ #
6
+ # StatC is free software: you can redistribute it and/or modify it
7
+ # under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # StatC is distributed in the hope that it will be useful, but WITHOUT
12
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13
+ # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
14
+ # License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with StatC. If not, see <http://www.gnu.org/licenses/>.
18
+
19
+ # module StatC
20
+ # module Error
21
+ # class Error < StandardError
22
+ # end
23
+
24
+ # class ArgumentError < Error
25
+ # end
26
+ # end
27
+ # end
@@ -0,0 +1,3 @@
1
+ module StatC
2
+ VERSION = "0.1.0"
3
+ end
data/lib/stat_c.rb ADDED
@@ -0,0 +1,6 @@
1
+ require "stat_c/stat_c" # the C ext
2
+ require "stat_c/version"
3
+ require "stat_c/error/error"
4
+
5
+ module StatC
6
+ end
data/stat_c.gemspec ADDED
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'stat_c/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "stat_c"
8
+ spec.version = StatC::VERSION
9
+ spec.authors = ["Ryan Moore"]
10
+ spec.email = ["moorer@udel.edu"]
11
+ spec.license = "GPLv3"
12
+
13
+ spec.summary = %q{Fast statistics library. C extension.}
14
+ spec.description = %q{Fast statistics library. C extension.}
15
+ spec.homepage = "https://github.com/mooreryan/stat_c"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib", "ext"]
21
+
22
+ spec.platform = Gem::Platform::RUBY
23
+ spec.extensions = ["ext/stat_c/extconf.rb"]
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.11"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "rake-compiler", "~> 0.9.7"
28
+ spec.add_development_dependency "rspec", "~> 3.0"
29
+ spec.add_development_dependency "guard-rspec", "~> 4.6", ">= 4.6.4"
30
+ spec.add_development_dependency "yard", "~> 0.8.7.6"
31
+ spec.add_development_dependency "coveralls", "~> 0.8.11"
32
+ end
metadata ADDED
@@ -0,0 +1,169 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: stat_c
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Ryan Moore
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-06-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.11'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.11'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake-compiler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.9.7
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.9.7
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: guard-rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '4.6'
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: 4.6.4
79
+ type: :development
80
+ prerelease: false
81
+ version_requirements: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - "~>"
84
+ - !ruby/object:Gem::Version
85
+ version: '4.6'
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: 4.6.4
89
+ - !ruby/object:Gem::Dependency
90
+ name: yard
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: 0.8.7.6
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: 0.8.7.6
103
+ - !ruby/object:Gem::Dependency
104
+ name: coveralls
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: 0.8.11
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: 0.8.11
117
+ description: Fast statistics library. C extension.
118
+ email:
119
+ - moorer@udel.edu
120
+ executables: []
121
+ extensions:
122
+ - ext/stat_c/extconf.rb
123
+ extra_rdoc_files: []
124
+ files:
125
+ - ".gitignore"
126
+ - ".rspec"
127
+ - ".ruby-gemset"
128
+ - ".ruby-version"
129
+ - ".travis.yml"
130
+ - CODE_OF_CONDUCT.md
131
+ - Gemfile
132
+ - README.md
133
+ - Rakefile
134
+ - benchmark/benchmark.rb
135
+ - bin/console
136
+ - bin/setup
137
+ - ext/stat_c/extconf.rb
138
+ - ext/stat_c/stat_c.c
139
+ - lib/stat_c.rb
140
+ - lib/stat_c/error/error.rb
141
+ - lib/stat_c/version.rb
142
+ - stat_c.gemspec
143
+ homepage: https://github.com/mooreryan/stat_c
144
+ licenses:
145
+ - GPLv3
146
+ metadata: {}
147
+ post_install_message:
148
+ rdoc_options: []
149
+ require_paths:
150
+ - lib
151
+ - ext
152
+ required_ruby_version: !ruby/object:Gem::Requirement
153
+ requirements:
154
+ - - ">="
155
+ - !ruby/object:Gem::Version
156
+ version: '0'
157
+ required_rubygems_version: !ruby/object:Gem::Requirement
158
+ requirements:
159
+ - - ">="
160
+ - !ruby/object:Gem::Version
161
+ version: '0'
162
+ requirements: []
163
+ rubyforge_project:
164
+ rubygems_version: 2.5.1
165
+ signing_key:
166
+ specification_version: 4
167
+ summary: Fast statistics library. C extension.
168
+ test_files: []
169
+ has_rdoc: