symbo 0.1.0pre

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 5637372acf581446bfa482ac16911b16908b908f66d8ab8b01f3cbbf662b9f12
4
+ data.tar.gz: 4c542c4016b8a5dc6706425084268ee73b6fe3fbd293c9b93e96d3f2d0c61f81
5
+ SHA512:
6
+ metadata.gz: 8a11998bf1e61269d59441094e27c1a236631eab7f09df9c0ab68587dad0e6d333b0ed76ca1efc2c036f2ef3237dc982ba32b20a17594ff0b5039bafb7230aea
7
+ data.tar.gz: 80f046d40ac4b852fdd4fa317e31fd41e6f874137afc0ecdfbeb7762ef53376135ef7c9604d8f6e8549e8498cd444108d98d61eb6e8f9c3cdfd618d62d30e1f1
@@ -0,0 +1,26 @@
1
+ name: Ruby
2
+
3
+ on: [push]
4
+
5
+ jobs:
6
+ build:
7
+
8
+ runs-on: ubuntu-latest
9
+
10
+ steps:
11
+ - uses: actions/checkout@v1
12
+ - name: Set up Ruby 2.7
13
+ uses: actions/setup-ruby@v1
14
+ with:
15
+ ruby-version: 2.7.0
16
+ - name: Bundle install
17
+ run: |
18
+ gem install bundler
19
+ bundle install --jobs 4 --retry 3
20
+ - name: Test & publish code coverage
21
+ uses: paambaati/codeclimate-action@v2.4.0
22
+ env:
23
+ CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
24
+ with:
25
+ coverageCommand: bundle exec rake
26
+ debug: true
@@ -0,0 +1,56 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ # Used by dotenv library to load environment variables.
14
+ # .env
15
+
16
+ # Ignore Byebug command history file.
17
+ .byebug_history
18
+
19
+ ## Specific to RubyMotion:
20
+ .dat*
21
+ .repl_history
22
+ build/
23
+ *.bridgesupport
24
+ build-iPhoneOS/
25
+ build-iPhoneSimulator/
26
+
27
+ ## Specific to RubyMotion (use of CocoaPods):
28
+ #
29
+ # We recommend against adding the Pods directory to your .gitignore. However
30
+ # you should judge for yourself, the pros and cons are mentioned at:
31
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
32
+ #
33
+ # vendor/Pods/
34
+
35
+ ## Documentation cache and generated files:
36
+ /.yardoc/
37
+ /_yardoc/
38
+ /doc/
39
+ /rdoc/
40
+
41
+ ## Environment normalization:
42
+ /.bundle/
43
+ /vendor/bundle
44
+ /lib/bundler/man/
45
+
46
+ # for a library or gem, you might want to ignore these files since the code is
47
+ # intended to run in multiple environments; otherwise, check them in:
48
+ # Gemfile.lock
49
+ # .ruby-version
50
+ # .ruby-gemset
51
+
52
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
53
+ .rvmrc
54
+
55
+ # Used by RuboCop. Remote config files pulled in from inherit_from directive.
56
+ # .rubocop-https?--*
@@ -0,0 +1,31 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.7
3
+
4
+ # コメントは日本語で OK
5
+ Style/AsciiComments:
6
+ Enabled: false
7
+
8
+ Style/Documentation:
9
+ Enabled: false
10
+
11
+ # 行の文字数を制限しない
12
+ Layout/LineLength:
13
+ Enabled: false
14
+
15
+ Layout/SpaceAroundOperators:
16
+ Enabled: false
17
+
18
+ # クラスの長さを制限しない
19
+ Metrics/ClassLength:
20
+ Enabled: false
21
+
22
+ # モジュールの長さを制限しない
23
+ Metrics/ModuleLength:
24
+ Enabled: false
25
+
26
+ # メソッドの長さを制限しない
27
+ Metrics/MethodLength:
28
+ Enabled: false
29
+
30
+ Naming/AsciiIdentifiers:
31
+ Enabled: false
@@ -0,0 +1 @@
1
+ 2.7.0
File without changes
data/Gemfile ADDED
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+ ruby '2.7.0'
5
+
6
+ gemspec
7
+
8
+ group :development do
9
+ gem 'rubocop'
10
+ end
11
+
12
+ group :development, :test do
13
+ gem 'activesupport'
14
+ end
15
+
16
+ group :test do
17
+ gem 'simplecov', '~> 0.17.1', require: false
18
+ gem 'simplecov-html', '~> 0.10.0'
19
+ end
@@ -0,0 +1,65 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ symbo (0.1.0pre)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ activesupport (6.0.2.1)
10
+ concurrent-ruby (~> 1.0, >= 1.0.2)
11
+ i18n (>= 0.7, < 2)
12
+ minitest (~> 5.1)
13
+ tzinfo (~> 1.1)
14
+ zeitwerk (~> 2.2)
15
+ ast (2.4.0)
16
+ concurrent-ruby (1.1.6)
17
+ docile (1.3.2)
18
+ i18n (1.8.2)
19
+ concurrent-ruby (~> 1.0)
20
+ jaro_winkler (1.5.4)
21
+ json (2.3.0)
22
+ minitest (5.14.0)
23
+ parallel (1.19.1)
24
+ parser (2.7.0.4)
25
+ ast (~> 2.4.0)
26
+ rainbow (3.0.0)
27
+ rake (13.0.1)
28
+ rexml (3.2.4)
29
+ rubocop (0.80.1)
30
+ jaro_winkler (~> 1.5.1)
31
+ parallel (~> 1.10)
32
+ parser (>= 2.7.0.1)
33
+ rainbow (>= 2.2.2, < 4.0)
34
+ rexml
35
+ ruby-progressbar (~> 1.7)
36
+ unicode-display_width (>= 1.4.0, < 1.7)
37
+ ruby-progressbar (1.10.1)
38
+ simplecov (0.17.1)
39
+ docile (~> 1.1)
40
+ json (>= 1.8, < 3)
41
+ simplecov-html (~> 0.10.0)
42
+ simplecov-html (0.10.2)
43
+ thread_safe (0.3.6)
44
+ tzinfo (1.2.6)
45
+ thread_safe (~> 0.1)
46
+ unicode-display_width (1.6.1)
47
+ zeitwerk (2.2.2)
48
+
49
+ PLATFORMS
50
+ ruby
51
+
52
+ DEPENDENCIES
53
+ activesupport
54
+ bundler
55
+ rake
56
+ rubocop
57
+ simplecov (~> 0.17.1)
58
+ simplecov-html (~> 0.10.0)
59
+ symbo!
60
+
61
+ RUBY VERSION
62
+ ruby 2.7.0p0
63
+
64
+ BUNDLED WITH
65
+ 2.1.4
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Yasuhito Takamiya
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,37 @@
1
+ # Symbo
2
+
3
+ A simple CAS (computer algebra system) in Ruby
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'symbo'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install symbo
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Development
26
+
27
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
28
+
29
+ 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).
30
+
31
+ ## Contributing
32
+
33
+ Bug reports and pull requests are welcome on GitHub at https://github.com/yasuhito/symbo.
34
+
35
+ ## License
36
+
37
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rake/testtask'
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << 'test'
8
+ t.libs << 'lib'
9
+ t.test_files = FileList['test/**/*_test.rb']
10
+ end
11
+
12
+ task default: :test
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "symbo"
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(__FILE__)
@@ -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,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "symbo/version"
4
+
5
+ require 'symbo/integer'
6
+ require 'symbo/symbol'
7
+
8
+ require 'symbo/complex'
9
+ require 'symbo/cos'
10
+ require 'symbo/diff'
11
+ require 'symbo/e'
12
+ require 'symbo/matrix'
13
+ require 'symbo/pi'
14
+ require 'symbo/power'
15
+ require 'symbo/product'
16
+ require 'symbo/qubit'
17
+ require 'symbo/quot'
18
+ require 'symbo/sin'
19
+ require 'symbo/sqrt'
20
+ require 'symbo/sum'
21
+ require 'symbo/tensor_product'
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Symbo
4
+ module AlgebraicOperators
5
+ using Symbo
6
+
7
+ def +(other)
8
+ Sum[self, other]
9
+ end
10
+
11
+ def -@
12
+ Product[-1, self]
13
+ end
14
+
15
+ def *(other)
16
+ if other.is_a?(Matrix)
17
+ other.map { |each| Product[self, each].simplify }
18
+ else
19
+ Product[self, other]
20
+ end
21
+ end
22
+
23
+ def /(other)
24
+ if (is_a?(Integer) || is_a?(Complex)) && other.is_a?(Integer)
25
+ Fraction[self, other]
26
+ else
27
+ Quot[self, other]
28
+ end
29
+ end
30
+
31
+ def **(other)
32
+ Power[self, other]
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,78 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'symbo/constant'
4
+ require 'symbo/expression_type'
5
+
6
+ module Symbo
7
+ refine Complex do
8
+ include AlgebraicOperators
9
+ include ExpressionType
10
+ include Constant
11
+
12
+ def simplify
13
+ dup
14
+ end
15
+
16
+ def evaluate
17
+ dup
18
+ end
19
+
20
+ def simplify_rational_number
21
+ dup
22
+ end
23
+
24
+ def simplify_rne_rec
25
+ dup
26
+ end
27
+
28
+ def base
29
+ UNDEFINED
30
+ end
31
+
32
+ def compare(other)
33
+ case other
34
+ when Integer
35
+ false
36
+ when Symbol
37
+ other == PI
38
+ else
39
+ true
40
+ end
41
+ end
42
+
43
+ def to_s
44
+ if real.zero?
45
+ if imag == 1
46
+ 'i'
47
+ else
48
+ "#{imag}i"
49
+ end
50
+ elsif imag == 1
51
+ "(#{real} + i)"
52
+ else
53
+ "(#{real} + #{imag}i)"
54
+ end
55
+ end
56
+ end
57
+ end
58
+
59
+ # Matrix などの中で使われる Complex#+ などをハイジャック
60
+ class Complex
61
+ include Symbo::Constant
62
+ include Symbo::ExpressionType
63
+
64
+ alias plus +
65
+ alias mult *
66
+
67
+ def +(other)
68
+ plus other
69
+ rescue TypeError
70
+ Symbo::Sum[self, other]
71
+ end
72
+
73
+ def *(other)
74
+ mult other
75
+ rescue TypeError
76
+ Symbo::Product[self, other]
77
+ end
78
+ end