diff --git a/docs/Apatite.html b/docs/Apatite.html index 86b9301..64c797d 100644 --- a/docs/Apatite.html +++ b/docs/Apatite.html @@ -131,28 +131,28 @@ of Crystal.

Defined in:

- + apatite/linear_algebra/ndarray.cr
- + apatite/linear_algebra.cr
- + apatite.cr
- + apatite/version.cr @@ -368,7 +368,7 @@ of Crystal.


- [View source] + [View source]
@@ -386,7 +386,7 @@ of Crystal.


- [View source] + [View source]
@@ -404,7 +404,7 @@ of Crystal.


- [View source] + [View source]
@@ -422,7 +422,7 @@ of Crystal.


- [View source] + [View source]
@@ -442,7 +442,7 @@ of Crystal.


- [View source] + [View source]
@@ -461,7 +461,7 @@ and zeros elsewhere.


- [View source] + [View source]
@@ -479,7 +479,7 @@ and zeros elsewhere.


- [View source] + [View source]
@@ -497,7 +497,7 @@ and zeros elsewhere.


- [View source] + [View source]
@@ -515,7 +515,7 @@ and zeros elsewhere.


- [View source] + [View source]
@@ -535,7 +535,7 @@ to a given range.


- [View source] + [View source]
@@ -553,7 +553,7 @@ to a given range.


- [View source] + [View source]
@@ -571,7 +571,7 @@ to a given range.


- [View source] + [View source]
@@ -590,7 +590,7 @@ for each index of self, assigning the block's value in that index.<
- [View source] + [View source]
@@ -608,7 +608,7 @@ for each index of self, assigning the block's value in that index.<
- [View source] + [View source]
diff --git a/docs/Apatite/LinearAlgebra.html b/docs/Apatite/LinearAlgebra.html index c110d3b..4305b0c 100644 --- a/docs/Apatite/LinearAlgebra.html +++ b/docs/Apatite/LinearAlgebra.html @@ -123,28 +123,28 @@

Defined in:

- + apatite/linear_algebra/ndarray.cr
- + apatite/linear_algebra/vector.cr
- + apatite/linear_algebra/matrix.cr
- + apatite/linear_algebra.cr @@ -210,7 +210,7 @@
- [View source] + [View source]
@@ -230,7 +230,7 @@
- [View source] + [View source]
diff --git a/docs/Apatite/LinearAlgebra/Matrix.html b/docs/Apatite/LinearAlgebra/Matrix.html index 037e4a4..63f1d74 100644 --- a/docs/Apatite/LinearAlgebra/Matrix.html +++ b/docs/Apatite/LinearAlgebra/Matrix.html @@ -122,7 +122,7 @@

Defined in:

- + apatite/linear_algebra/matrix.cr @@ -539,7 +539,7 @@
- [View source] + [View source]
@@ -562,7 +562,7 @@
- [View source] + [View source]
@@ -581,7 +581,7 @@ the given block, passing the current row and column.


- [View source] + [View source]
@@ -599,7 +599,7 @@ the given block, passing the current row and column.


- [View source] + [View source]
@@ -617,7 +617,7 @@ the given block, passing the current row and column.


- [View source] + [View source]
@@ -635,7 +635,7 @@ the given block, passing the current row and column.


- [View source] + [View source]
@@ -653,7 +653,7 @@ the given block, passing the current row and column.


- [View source] + [View source]
@@ -672,7 +672,7 @@ the given block, passing the current row and column.


- [View source] + [View source]
@@ -691,7 +691,7 @@ and zeros elsewhere.


- [View source] + [View source]
@@ -709,7 +709,7 @@ and zeros elsewhere.


- [View source] + [View source]
@@ -727,7 +727,7 @@ and zeros elsewhere.


- [View source] + [View source]
@@ -745,7 +745,7 @@ and zeros elsewhere.


- [View source] + [View source]
@@ -763,7 +763,7 @@ and zeros elsewhere.


- [View source] + [View source]
@@ -781,7 +781,7 @@ and zeros elsewhere.


- [View source] + [View source]
@@ -799,7 +799,7 @@ and zeros elsewhere.


- [View source] + [View source]
@@ -817,7 +817,7 @@ and zeros elsewhere.


- [View source] + [View source]
@@ -838,7 +838,7 @@ and zeros elsewhere.


- [View source] + [View source]
@@ -854,7 +854,7 @@ and zeros elsewhere.


- [View source] + [View source]
@@ -870,7 +870,7 @@ and zeros elsewhere.


- [View source] + [View source]
@@ -886,7 +886,7 @@ and zeros elsewhere.


- [View source] + [View source]
@@ -902,7 +902,7 @@ and zeros elsewhere.


- [View source] + [View source]
@@ -918,7 +918,7 @@ and zeros elsewhere.


- [View source] + [View source]
@@ -934,7 +934,7 @@ and zeros elsewhere.


- [View source] + [View source]
@@ -950,7 +950,7 @@ and zeros elsewhere.


- [View source] + [View source]
@@ -966,7 +966,7 @@ and zeros elsewhere.


- [View source] + [View source]
@@ -982,7 +982,7 @@ and zeros elsewhere.


- [View source] + [View source]
@@ -998,7 +998,7 @@ and zeros elsewhere.


- [View source] + [View source]
@@ -1016,7 +1016,7 @@ and zeros elsewhere.


- [View source] + [View source]
@@ -1034,7 +1034,7 @@ and zeros elsewhere.


- [View source] + [View source]
@@ -1052,7 +1052,7 @@ and zeros elsewhere.


- [View source] + [View source]
@@ -1070,7 +1070,7 @@ and zeros elsewhere.


- [View source] + [View source]
@@ -1088,7 +1088,7 @@ and zeros elsewhere.


- [View source] + [View source]
@@ -1106,7 +1106,7 @@ and zeros elsewhere.


- [View source] + [View source]
@@ -1124,7 +1124,7 @@ and zeros elsewhere.


- [View source] + [View source]
@@ -1140,7 +1140,7 @@ and zeros elsewhere.


- [View source] + [View source]
@@ -1158,7 +1158,7 @@ and zeros elsewhere.


- [View source] + [View source]
@@ -1174,7 +1174,7 @@ and zeros elsewhere.


- [View source] + [View source]
@@ -1190,7 +1190,7 @@ and zeros elsewhere.


- [View source] + [View source]
@@ -1208,7 +1208,7 @@ and zeros elsewhere.


- [View source] + [View source]
@@ -1226,7 +1226,7 @@ and zeros elsewhere.


- [View source] + [View source]
@@ -1242,7 +1242,7 @@ and zeros elsewhere.


- [View source] + [View source]
@@ -1258,7 +1258,7 @@ and zeros elsewhere.


- [View source] + [View source]
@@ -1274,7 +1274,7 @@ and zeros elsewhere.


- [View source] + [View source]
@@ -1290,7 +1290,7 @@ and zeros elsewhere.


- [View source] + [View source]
@@ -1306,7 +1306,7 @@ and zeros elsewhere.


- [View source] + [View source]
@@ -1322,7 +1322,7 @@ and zeros elsewhere.


- [View source] + [View source]
@@ -1338,7 +1338,7 @@ and zeros elsewhere.


- [View source] + [View source]
@@ -1354,7 +1354,7 @@ and zeros elsewhere.


- [View source] + [View source]
@@ -1370,7 +1370,7 @@ and zeros elsewhere.


- [View source] + [View source]
diff --git a/docs/Apatite/LinearAlgebra/NDArray.html b/docs/Apatite/LinearAlgebra/NDArray.html index db9f32a..d2f1e83 100644 --- a/docs/Apatite/LinearAlgebra/NDArray.html +++ b/docs/Apatite/LinearAlgebra/NDArray.html @@ -122,7 +122,7 @@

Defined in:

- + apatite/linear_algebra/ndarray.cr @@ -323,7 +323,7 @@
- [View source] + [View source]
@@ -346,7 +346,7 @@
- [View source] + [View source]
@@ -362,7 +362,7 @@
- [View source] + [View source]
@@ -378,7 +378,7 @@
- [View source] + [View source]
@@ -394,7 +394,7 @@
- [View source] + [View source]
@@ -410,7 +410,7 @@
- [View source] + [View source]
@@ -428,7 +428,7 @@
- [View source] + [View source]
@@ -446,7 +446,7 @@
- [View source] + [View source]
@@ -462,7 +462,7 @@
- [View source] + [View source]
@@ -478,7 +478,7 @@
- [View source] + [View source]
@@ -494,7 +494,7 @@
- [View source] + [View source]
@@ -510,7 +510,7 @@
- [View source] + [View source]
@@ -526,7 +526,7 @@
- [View source] + [View source]
@@ -542,7 +542,7 @@
- [View source] + [View source]
@@ -558,7 +558,7 @@
- [View source] + [View source]
@@ -574,7 +574,7 @@
- [View source] + [View source]
diff --git a/docs/Apatite/LinearAlgebra/Vector.html b/docs/Apatite/LinearAlgebra/Vector.html index 7ffcf8d..00171cd 100644 --- a/docs/Apatite/LinearAlgebra/Vector.html +++ b/docs/Apatite/LinearAlgebra/Vector.html @@ -127,7 +127,7 @@ of a MatrixDefined in: - + apatite/linear_algebra/vector.cr @@ -773,7 +773,7 @@ and yielding that buffer. The given block must return the desired size of the ve
- [View source] + [View source]
@@ -793,7 +793,7 @@ and yielding that buffer. The given block must return the desired size of the ve
- [View source] + [View source]
@@ -820,7 +820,7 @@ vec.size # => 0
- [View source] + [View source]
@@ -838,7 +838,7 @@ vec.size # => 0
- [View source] + [View source]
@@ -862,7 +862,7 @@ vec # => Vector{5.0, 5.0, 5.0}
- [View source] + [View source]
@@ -883,7 +883,7 @@ vec # => Vector{5.0, 5.0, 5.0}
- [View source] + [View source]
@@ -901,7 +901,7 @@ vec # => Vector{5.0, 5.0, 5.0}
- [View source] + [View source]
@@ -922,7 +922,7 @@ collection.


- [View source] + [View source]
@@ -940,7 +940,7 @@ collection.


- [View source] + [View source]
@@ -960,7 +960,7 @@ to a given range.


- [View source] + [View source]
@@ -978,7 +978,7 @@ to a given range.


- [View source] + [View source]
@@ -999,7 +999,7 @@ to a given range.


- [View source] + [View source]
@@ -1015,7 +1015,7 @@ to a given range.


- [View source] + [View source]
@@ -1031,7 +1031,7 @@ to a given range.


- [View source] + [View source]
@@ -1049,7 +1049,7 @@ to a given range.


- [View source] + [View source]
@@ -1078,7 +1078,7 @@ value, that result is the return value of the comparison.


- [View source] + [View source]
@@ -1094,7 +1094,7 @@ value, that result is the return value of the comparison.


- [View source] + [View source]
@@ -1123,7 +1123,7 @@ v[6, 10] # raise I
- [View source] + [View source]
@@ -1151,7 +1151,7 @@ v[6..10] # raise I
- [View source] + [View source]
@@ -1177,7 +1177,7 @@ vec # = Vector{1.0, 6.0, 7.0, 5.0}
- [View source] + [View source]
@@ -1209,7 +1209,7 @@ vec # => Vector{1.0, 6.0, 2.0, 3.0, 4.0, 5.0}
- [View source] + [View source]
@@ -1236,7 +1236,7 @@ vec[3] = 5.0
- [View source] + [View source]
@@ -1262,7 +1262,7 @@ vec # = Vector{1.0, 6.0, 2.0, 3.0, 4.0, 5.0}
- [View source] + [View source]
@@ -1282,7 +1282,7 @@ will be added together.


- [View source] + [View source]
@@ -1301,7 +1301,7 @@ If the vectors are mirrored across their axes this will return nil.
- [View source] + [View source]
@@ -1319,7 +1319,7 @@ If the vectors are mirrored across their axes this will return nil.
- [View source] + [View source]
@@ -1338,7 +1338,7 @@ on the end.


- [View source] + [View source]
@@ -1357,7 +1357,7 @@ the beginning.


- [View source] + [View source]
@@ -1378,7 +1378,7 @@ vec.clear # => Vector{}
- [View source] + [View source]
@@ -1394,7 +1394,7 @@ vec.clear # => Vector{}
- [View source] + [View source]
@@ -1410,7 +1410,7 @@ vec.clear # => Vector{}
- [View source] + [View source]
@@ -1428,7 +1428,7 @@ vec.clear # => Vector{}
- [View source] + [View source]
@@ -1450,7 +1450,7 @@ v1.cross(v2) => Vector{0.0,
- [View source] + [View source]
@@ -1469,7 +1469,7 @@ a point in space.


- [View source] + [View source]
@@ -1489,7 +1489,7 @@ a point in space.


- [View source] + [View source]
@@ -1508,7 +1508,7 @@ is out of bounds. Indexing starts from 1.


- [View source] + [View source]
@@ -1526,7 +1526,7 @@ is out of bounds. Indexing starts from 1.


- [View source] + [View source]
@@ -1544,7 +1544,7 @@ is out of bounds. Indexing starts from 1.


- [View source] + [View source]
@@ -1562,7 +1562,7 @@ is out of bounds. Indexing starts from 1.


- [View source] + [View source]
@@ -1580,7 +1580,7 @@ is out of bounds. Indexing starts from 1.


- [View source] + [View source]
@@ -1600,7 +1600,7 @@ is out of bounds. Indexing starts from 1.


- [View source] + [View source]
@@ -1618,7 +1618,7 @@ is out of bounds. Indexing starts from 1.


- [View source] + [View source]
@@ -1641,7 +1641,7 @@ a # => Vector{1.0, 4.0, 9.0}
- [View source] + [View source]
@@ -1659,7 +1659,7 @@ a # => Vector{1.0, 4.0, 9.0}
- [View source] + [View source]
@@ -1677,7 +1677,7 @@ a # => Vector{1.0, 4.0, 9.0}
- [View source] + [View source]
@@ -1695,7 +1695,7 @@ a # => Vector{1.0, 4.0, 9.0}
- [View source] + [View source]
@@ -1713,7 +1713,7 @@ a # => Vector{1.0, 4.0, 9.0}
- [View source] + [View source]
@@ -1733,7 +1733,7 @@ will be element-wise multiplied.


- [View source] + [View source]
@@ -1751,7 +1751,7 @@ will be element-wise multiplied.


- [View source] + [View source]
@@ -1769,7 +1769,7 @@ will be element-wise multiplied.


- [View source] + [View source]
@@ -1785,7 +1785,7 @@ will be element-wise multiplied.


- [View source] + [View source]
@@ -1803,7 +1803,7 @@ will be element-wise multiplied.


- [View source] + [View source]
@@ -1819,7 +1819,7 @@ will be element-wise multiplied.


- [View source] + [View source]
@@ -1835,7 +1835,7 @@ will be element-wise multiplied.


- [View source] + [View source]
@@ -1854,7 +1854,7 @@ will be element-wise multiplied.


- [View source] + [View source]
@@ -1874,7 +1874,7 @@ careful with line directions!


- [View source] + [View source]
@@ -1892,7 +1892,7 @@ careful with line directions!


- [View source] + [View source]
@@ -1908,7 +1908,7 @@ careful with line directions!


- [View source] + [View source]
@@ -1927,7 +1927,7 @@ across the whole vector.


- [View source] + [View source]
@@ -1945,7 +1945,7 @@ across the whole vector.


- [View source] + [View source]
@@ -1964,7 +1964,7 @@ they differ from it by less than Apetite.precision


- [View source] + [View source]
@@ -1984,7 +1984,7 @@ will be subtracted.


- [View source] + [View source]
@@ -2002,7 +2002,7 @@ will be subtracted.


- [View source] + [View source]
@@ -2021,7 +2021,7 @@ z-component is added.


- [View source] + [View source]
@@ -2037,7 +2037,7 @@ z-component is added.


- [View source] + [View source]
@@ -2056,7 +2056,7 @@ diagonal elements.


- [View source] + [View source]
@@ -2072,7 +2072,7 @@ diagonal elements.


- [View source] + [View source]
@@ -2092,7 +2092,7 @@ vector, it will not be modified.


- [View source] + [View source]
@@ -2116,7 +2116,7 @@ vec.to_unsafe[0] # => 1.0
- [View source] + [View source]
@@ -2134,7 +2134,7 @@ vec.to_unsafe[0] # => 1.0
- [View source] + [View source]
@@ -2152,7 +2152,7 @@ vec.to_unsafe[0] # => 1.0
- [View source] + [View source]
@@ -2168,7 +2168,7 @@ vec.to_unsafe[0] # => 1.0
- [View source] + [View source]
@@ -2184,7 +2184,7 @@ vec.to_unsafe[0] # => 1.0
- [View source] + [View source]
diff --git a/docs/Array.html b/docs/Array.html index 60ad937..6368dcb 100644 --- a/docs/Array.html +++ b/docs/Array.html @@ -160,7 +160,7 @@ set << 3

Defined in:

- + apatite/core_ext/array.cr @@ -294,7 +294,7 @@ set << 3
- [View source] + [View source]
@@ -312,7 +312,7 @@ set << 3
- [View source] + [View source]
@@ -330,7 +330,7 @@ set << 3
- [View source] + [View source]
@@ -346,7 +346,7 @@ set << 3
- [View source] + [View source]
diff --git a/docs/index.json b/docs/index.json index 3129052..a65997e 100644 --- a/docs/index.json +++ b/docs/index.json @@ -1 +1 @@ -{"repository_name":"github.com/watzon/apatite","body":"# Apatite\n\nApatite is meant to be a collecion of mathmatical and scientific computing algorithms for the Crystal programming language. I don't expect it to ever reach the level of completeness as numpy, but hopefully it can save some people the trouble of implementing these methods on their own.\n\n## Installation\n\n1. Add the dependency to your `shard.yml`:\n\n ```yaml\n dependencies:\n apatite:\n github: watzon/apatite\n ```\n\n2. Run `shards install`\n\n## Usage\n\n```crystal\nrequire \"apatite\"\n```\n\nTODO: Write usage instructions here, but first write the library...\n\n## Roadmap\n\n- [ ] Apetite\n\t- [ ] Vector Math\n\t\t- [ ] Matrix\n\t\t- [ ] NDArray\n\t\t- [x] Vector\n\t\t- [ ] Line\n\t\t- [ ] Plane\n\t\t- [ ] Polygon\n\t\t- [ ] LinkedList\n\t\n\n\n## Contributing\n\n1. Fork it ()\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n## Contributors\n\n- [Chris Watson](https://github.com/watzon) - creator and maintainer","program":{"html_id":"github.com/watzon/apatite/toplevel","path":"toplevel.html","kind":"module","full_name":"Top Level Namespace","name":"Top Level Namespace","abstract":false,"superclass":null,"ancestors":[],"locations":[],"repository_name":"github.com/watzon/apatite","program":true,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":null,"doc":null,"summary":null,"class_methods":[],"constructors":[],"instance_methods":[],"macros":[],"types":[{"html_id":"github.com/watzon/apatite/Apatite","path":"Apatite.html","kind":"module","full_name":"Apatite","name":"Apatite","abstract":false,"superclass":null,"ancestors":[{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra","kind":"module","full_name":"Apatite::LinearAlgebra","name":"LinearAlgebra"}],"locations":[{"filename":"apatite/linear_algebra/ndarray.cr","line_number":1,"url":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/ndarray.cr"},{"filename":"apatite/linear_algebra.cr","line_number":5,"url":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra.cr"},{"filename":"apatite.cr","line_number":10,"url":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite.cr"},{"filename":"apatite/version.cr","line_number":1,"url":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/version.cr"}],"repository_name":"github.com/watzon/apatite","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[{"id":"I","name":"I","value":"Vector::I","doc":"Cartesian unit vector I\n\n`Vector{1.0, 0.0, 0.0}`","summary":"

Cartesian unit vector I

"},{"id":"J","name":"J","value":"Vector::J","doc":"Cartesian unit vector J\n\n`Vector{0.0, 1.0, 0.0}`","summary":"

Cartesian unit vector J

"},{"id":"K","name":"K","value":"Vector::K","doc":"Cartesian unit vector K\n\n`Vector{0.0, 0.0, 1.0}`","summary":"

Cartesian unit vector K

"},{"id":"VERSION","name":"VERSION","value":"\"0.1.0\"","doc":null,"summary":null}],"included_modules":[{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra","kind":"module","full_name":"Apatite::LinearAlgebra","name":"LinearAlgebra"}],"extended_modules":[{"html_id":"github.com/watzon/apatite/Apatite","kind":"module","full_name":"Apatite","name":"Apatite"}],"subclasses":[],"including_types":[],"namespace":null,"doc":"Apatite is a fundimental package for scientific computing in Crystal. If that\nsounds like a modified version of the first line from the NumPy homepage,\nthat's because it is. Apatite has (ok, will have) all of the goodness\nof NumPy sitting atop the blazing speed and beautiful syntax\nof Crystal.","summary":"

Apatite is a fundimental package for scientific computing in Crystal.

","class_methods":[],"constructors":[],"instance_methods":[{"id":"as_vector(input:Indexable)-instance-method","html_id":"as_vector(input:Indexable)-instance-method","name":"as_vector","doc":"Creates a new vector from the given `input`. Input can be any\n`Indexable` type.","summary":"

Creates a new vector from the given input.

","abstract":false,"args":[{"name":"input","doc":null,"default_value":"","external_name":"input","restriction":"Indexable"}],"args_string":"(input : Indexable)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite.cr#L61","def":{"name":"as_vector","args":[{"name":"input","doc":null,"default_value":"","external_name":"input","restriction":"Indexable"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.create(input)"}},{"id":"basis(size,index)-instance-method","html_id":"basis(size,index)-instance-method","name":"basis","doc":"Creates a standard basis-n vector of the given `size` and `index`.","summary":"

Creates a standard basis-n vector of the given size and index.

","abstract":false,"args":[{"name":"size","doc":null,"default_value":"","external_name":"size","restriction":""},{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":""}],"args_string":"(size, index)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite.cr#L66","def":{"name":"basis","args":[{"name":"size","doc":null,"default_value":"","external_name":"size","restriction":""},{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.basis(size, index)"}},{"id":"diagonal(values)-instance-method","html_id":"diagonal(values)-instance-method","name":"diagonal","doc":"Creates a matrix where the diagonal elements are composed of `values`.","summary":"

Creates a matrix where the diagonal elements are composed of values.

","abstract":false,"args":[{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":""}],"args_string":"(values)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite.cr#L89","def":{"name":"diagonal","args":[{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.diagonal(values)"}},{"id":"empty-instance-method","html_id":"empty-instance-method","name":"empty","doc":"Returns a new empty `Vector`","summary":"

Returns a new empty Vector

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite.cr#L34","def":{"name":"empty","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.new"}},{"id":"empty_matrix(row_count=0,column_count=0)-instance-method","html_id":"empty_matrix(row_count=0,column_count=0)-instance-method","name":"empty_matrix","doc":"Creates a new empty matrix with the given `row_count` and\n`column_count`. At lease one of `row_count` or\n`column_count` must be zero.","summary":"

Creates a new empty matrix with the given row_count and column_count.

","abstract":false,"args":[{"name":"row_count","doc":null,"default_value":"0","external_name":"row_count","restriction":""},{"name":"column_count","doc":null,"default_value":"0","external_name":"column_count","restriction":""}],"args_string":"(row_count = 0, column_count = 0)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite.cr#L84","def":{"name":"empty_matrix","args":[{"name":"row_count","doc":null,"default_value":"0","external_name":"row_count","restriction":""},{"name":"column_count","doc":null,"default_value":"0","external_name":"column_count","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.new(rows, column_count)"}},{"id":"eye(n)-instance-method","html_id":"eye(n)-instance-method","name":"eye","doc":"Creates a new diagonal matrix of size `n` with ones in the diagonal\nand zeros elsewhere.","summary":"

Creates a new diagonal matrix of size n with ones in the diagonal and zeros elsewhere.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite.cr#L95","def":{"name":"eye","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.eye(n)"}},{"id":"full(n,i)-instance-method","html_id":"full(n,i)-instance-method","name":"full","doc":"Returns a new vector of size `n` filled with `i`","summary":"

Returns a new vector of size n filled with i

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""},{"name":"i","doc":null,"default_value":"","external_name":"i","restriction":""}],"args_string":"(n, i)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite.cr#L49","def":{"name":"full","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""},{"name":"i","doc":null,"default_value":"","external_name":"i","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.new(n, i)"}},{"id":"identity(n)-instance-method","html_id":"identity(n)-instance-method","name":"identity","doc":"Creates a `n x n` identity matrix.","summary":"

Creates a n x n identity matrix.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite.cr#L100","def":{"name":"identity","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.identity(n)"}},{"id":"ones(n)-instance-method","html_id":"ones(n)-instance-method","name":"ones","doc":"Returns a new vector filled with `n` ones.","summary":"

Returns a new vector filled with n ones.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite.cr#L39","def":{"name":"ones","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.ones(n)"}},{"id":"random(n,range=nil)-instance-method","html_id":"random(n,range=nil)-instance-method","name":"random","doc":"Creates a new vector of size `n` filled with random numbers. A `range`\ncan optionally be passed in if you want to limit the random numbers\nto a given range.","summary":"

Creates a new vector of size n filled with random numbers.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""},{"name":"range","doc":null,"default_value":"nil","external_name":"range","restriction":""}],"args_string":"(n, range = nil)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite.cr#L73","def":{"name":"random","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""},{"name":"range","doc":null,"default_value":"nil","external_name":"range","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.random(n, range)"}},{"id":"row_vector(row)-instance-method","html_id":"row_vector(row)-instance-method","name":"row_vector","doc":"Creates a single-row matrix where the values of that row are as given in `row`.","summary":"

Creates a single-row matrix where the values of that row are as given in row.

","abstract":false,"args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":""}],"args_string":"(row)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite.cr#L105","def":{"name":"row_vector","args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.row_vector(row)"}},{"id":"scalar(n,value)-instance-method","html_id":"scalar(n,value)-instance-method","name":"scalar","doc":"Creates an `n` by `n` diagonal matrix where each diagonal element is value.","summary":"

Creates an n by n diagonal matrix where each diagonal element is value.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(n, value)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite.cr#L110","def":{"name":"scalar","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.scalar(n, value)"}},{"id":"vector(n,&block)-instance-method","html_id":"vector(n,&block)-instance-method","name":"vector","doc":"Creates a new vector of size `n`, and invokes the block once\nfor each index of `self`, assigning the block's value in that index.","summary":"

Creates a new vector of size n, and invokes the block once for each index of self, assigning the block's value in that index.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n, &block)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite.cr#L55","def":{"name":"vector","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.new(n) do |i|\n yield i\nend"}},{"id":"zeros(n)-instance-method","html_id":"zeros(n)-instance-method","name":"zeros","doc":"Returns a new vector filled with `n` zeros.","summary":"

Returns a new vector filled with n zeros.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite.cr#L44","def":{"name":"zeros","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.zeros(n)"}}],"macros":[],"types":[{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra","path":"Apatite/LinearAlgebra.html","kind":"module","full_name":"Apatite::LinearAlgebra","name":"LinearAlgebra","abstract":false,"superclass":null,"ancestors":[],"locations":[{"filename":"apatite/linear_algebra/ndarray.cr","line_number":1,"url":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/ndarray.cr"},{"filename":"apatite/linear_algebra/vector.cr","line_number":1,"url":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr"},{"filename":"apatite/linear_algebra/matrix.cr","line_number":3,"url":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr"},{"filename":"apatite/linear_algebra.cr","line_number":6,"url":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra.cr"}],"repository_name":"github.com/watzon/apatite","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[],"extended_modules":[{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra","kind":"module","full_name":"Apatite::LinearAlgebra","name":"LinearAlgebra"}],"subclasses":[],"including_types":[{"html_id":"github.com/watzon/apatite/Apatite","kind":"module","full_name":"Apatite","name":"Apatite"}],"namespace":{"html_id":"github.com/watzon/apatite/Apatite","kind":"module","full_name":"Apatite","name":"Apatite"},"doc":null,"summary":null,"class_methods":[],"constructors":[],"instance_methods":[{"id":"sigmoid(input:Number)-instance-method","html_id":"sigmoid(input:Number)-instance-method","name":"sigmoid","doc":"Calculates the sigmoid curve for a numeric input.\n\n`f(x) = 1/(1 + e^-x)`\n\nSee also: [Sigmoid function (WikiWand)](https://www.wikiwand.com/en/Sigmoid_function)","summary":"

Calculates the sigmoid curve for a numeric input.

","abstract":false,"args":[{"name":"input","doc":null,"default_value":"","external_name":"input","restriction":"Number"}],"args_string":"(input : Number)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra.cr#L14","def":{"name":"sigmoid","args":[{"name":"input","doc":null,"default_value":"","external_name":"input","restriction":"Number"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"num = input.to_f64\n1 / (1 + (Math.exp(-num)))\n"}},{"id":"sigmoid_d(input:Number)-instance-method","html_id":"sigmoid_d(input:Number)-instance-method","name":"sigmoid_d","doc":"Calculates the derivative sigmoid curve for a numeric input.\n\n`f'(x) = f(x)(1 - f(x)),`","summary":"

Calculates the derivative sigmoid curve for a numeric input.

","abstract":false,"args":[{"name":"input","doc":null,"default_value":"","external_name":"input","restriction":"Number"}],"args_string":"(input : Number)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra.cr#L22","def":{"name":"sigmoid_d","args":[{"name":"input","doc":null,"default_value":"","external_name":"input","restriction":"Number"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"num = input.to_f64\nnum * (1 - num)\n"}}],"macros":[],"types":[{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra/Matrix","path":"Apatite/LinearAlgebra/Matrix.html","kind":"class","full_name":"Apatite::LinearAlgebra::Matrix","name":"Matrix","abstract":false,"superclass":{"html_id":"github.com/watzon/apatite/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"github.com/watzon/apatite/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"github.com/watzon/apatite/Indexable","kind":"module","full_name":"Indexable","name":"Indexable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Iterable","kind":"module","full_name":"Iterable","name":"Iterable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"github.com/watzon/apatite/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"apatite/linear_algebra/matrix.cr","line_number":4,"url":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr"}],"repository_name":"github.com/watzon/apatite","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[{"html_id":"github.com/watzon/apatite/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Indexable","kind":"module","full_name":"Indexable","name":"Indexable"}],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra","kind":"module","full_name":"Apatite::LinearAlgebra","name":"LinearAlgebra"},"doc":null,"summary":null,"class_methods":[{"id":"[](*rows)-class-method","html_id":"[](*rows)-class-method","name":"[]","doc":"Creates a matrix where each argument is a row.","summary":"

Creates a matrix where each argument is a row.

","abstract":false,"args":[{"name":"rows","doc":null,"default_value":"","external_name":"rows","restriction":""}],"args_string":"(*rows)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L22","def":{"name":"[]","args":[{"name":"rows","doc":null,"default_value":"","external_name":"rows","restriction":""}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"rows(rows)"}},{"id":"build(row_count,column_count=row_count,&block)-class-method","html_id":"build(row_count,column_count=row_count,&block)-class-method","name":"build","doc":"Creates a matrix of size `row_count x column_count`. It fills the values by calling\nthe given block, passing the current row and column.","summary":"

Creates a matrix of size row_count x column_count.

","abstract":false,"args":[{"name":"row_count","doc":null,"default_value":"","external_name":"row_count","restriction":""},{"name":"column_count","doc":null,"default_value":"row_count","external_name":"column_count","restriction":""}],"args_string":"(row_count, column_count = row_count, &block)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L28","def":{"name":"build","args":[{"name":"row_count","doc":null,"default_value":"","external_name":"row_count","restriction":""},{"name":"column_count","doc":null,"default_value":"row_count","external_name":"column_count","restriction":""}],"double_splat":null,"splat_index":null,"yields":2,"block_arg":null,"return_type":"","visibility":"Public","body":"if row_count < 0 || column_count < 0\n raise(ArgumentError.new)\nend\nrows = Array.new(row_count) do |i|\n Vector.new(column_count) do |j|\n yield i, j\n end\nend\nMatrix.new(rows, column_count)\n"}},{"id":"col_vector(column)-class-method","html_id":"col_vector(column)-class-method","name":"col_vector","doc":"Creates a single-column matrix where the values of that column are as given in column.","summary":"

Creates a single-column matrix where the values of that column are as given in column.

","abstract":false,"args":[{"name":"column","doc":null,"default_value":"","external_name":"column","restriction":""}],"args_string":"(column)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L39","def":{"name":"col_vector","args":[{"name":"column","doc":null,"default_value":"","external_name":"column","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.new([column].transpose, 1)"}},{"id":"columns(columns)-class-method","html_id":"columns(columns)-class-method","name":"columns","doc":"Creates a matrix using `columns` as an array of column vectors.","summary":"

Creates a matrix using .columns as an array of column vectors.

","abstract":false,"args":[{"name":"columns","doc":null,"default_value":"","external_name":"columns","restriction":""}],"args_string":"(columns)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L44","def":{"name":"columns","args":[{"name":"columns","doc":null,"default_value":"","external_name":"columns","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"(rows(columns)).transpose"}},{"id":"diagonal(values)-class-method","html_id":"diagonal(values)-class-method","name":"diagonal","doc":"Creates a matrix where the diagonal elements are composed of `values`.","summary":"

Creates a matrix where the diagonal elements are composed of values.

","abstract":false,"args":[{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":""}],"args_string":"(values)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L70","def":{"name":"diagonal","args":[{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"size = values.size\nif size == 0\n return Matrix.empty\nend\nrows = Array.new(size) do |j|\n row = Array.new(size, 0)\n row[j] = values[j]\n row\nend\nnew(rows)\n"}},{"id":"diagonal(*values)-class-method","html_id":"diagonal(*values)-class-method","name":"diagonal","doc":"Creates a matrix where the diagonal elements are composed of `values`.","summary":"

Creates a matrix where the diagonal elements are composed of values.

","abstract":false,"args":[{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":""}],"args_string":"(*values)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L84","def":{"name":"diagonal","args":[{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":""}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.diagonal(values)"}},{"id":"empty(row_count=0,column_count=0)-class-method","html_id":"empty(row_count=0,column_count=0)-class-method","name":"empty","doc":"Creates a empty matrix of `row_count x column_count`. At least one of\n`row_count` or `column_count` must be 0.","summary":"

Creates a empty matrix of row_count x column_count.

","abstract":false,"args":[{"name":"row_count","doc":null,"default_value":"0","external_name":"row_count","restriction":""},{"name":"column_count","doc":null,"default_value":"0","external_name":"column_count","restriction":""}],"args_string":"(row_count = 0, column_count = 0)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L90","def":{"name":"empty","args":[{"name":"row_count","doc":null,"default_value":"0","external_name":"row_count","restriction":""},{"name":"column_count","doc":null,"default_value":"0","external_name":"column_count","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if (column_count != 0) && (row_count != 0)\n raise(ArgumentError.new(\"One size must be 0\"))\nend\nif column_count < 0 || row_count < 0\n raise(ArgumentError.new(\"Negative size\"))\nend\nMatrix.new(([] of Vector) * row_count, column_count)\n"}},{"id":"eye(n)-class-method","html_id":"eye(n)-class-method","name":"eye","doc":"Creates a new diagonal matrix of size `n` with ones in the diagonal\nand zeros elsewhere.","summary":"

Creates a new diagonal matrix of size n with ones in the diagonal and zeros elsewhere.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L98","def":{"name":"eye","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.diagonal([1] * n)"}},{"id":"hstack(x,*matrices)-class-method","html_id":"hstack(x,*matrices)-class-method","name":"hstack","doc":"TODO","summary":"

TODO

","abstract":false,"args":[{"name":"x","doc":null,"default_value":"","external_name":"x","restriction":""},{"name":"matrices","doc":null,"default_value":"","external_name":"matrices","restriction":""}],"args_string":"(x, *matrices)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L103","def":{"name":"hstack","args":[{"name":"x","doc":null,"default_value":"","external_name":"x","restriction":""},{"name":"matrices","doc":null,"default_value":"","external_name":"matrices","restriction":""}],"double_splat":null,"splat_index":1,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":""}},{"id":"identity(n)-class-method","html_id":"identity(n)-class-method","name":"identity","doc":"Creates a `n x n` identity matrix.","summary":"

Creates a n x n identity matrix.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L107","def":{"name":"identity","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"scalar(n, 1)"}},{"id":"row_vector(row)-class-method","html_id":"row_vector(row)-class-method","name":"row_vector","doc":"Creates a single-row matrix where the values of that row are as given in `row`.","summary":"

Creates a single-row matrix where the values of that row are as given in #row.

","abstract":false,"args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":""}],"args_string":"(row)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L112","def":{"name":"row_vector","args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.new([row], 0)"}},{"id":"rows(rows)-class-method","html_id":"rows(rows)-class-method","name":"rows","doc":"Creates a matrix where rows is an array of arrays, each of which is a row of the matrix.","summary":"

Creates a matrix where rows is an array of arrays, each of which is a row of the matrix.

","abstract":false,"args":[{"name":"rows","doc":null,"default_value":"","external_name":"rows","restriction":""}],"args_string":"(rows)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L117","def":{"name":"rows","args":[{"name":"rows","doc":null,"default_value":"","external_name":"rows","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"size = rows[0]? ? rows[0].size : 0\nrows.each do |row|\n if row.size == size\n else\n raise(\"Dimension mismatch: row size differs (#{row.size} should be #{size})\")\n end\nend\nMatrix.new(rows, size)\n"}},{"id":"scalar(n,value)-class-method","html_id":"scalar(n,value)-class-method","name":"scalar","doc":"Creates an `n` by `n` diagonal matrix where each diagonal element is value.","summary":"

Creates an n by n diagonal matrix where each diagonal element is value.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(n, value)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L126","def":{"name":"scalar","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.diagonal(Array.new(n, value))"}},{"id":"vstack(x,y)-class-method","html_id":"vstack(x,y)-class-method","name":"vstack","doc":"TODO","summary":"

TODO

","abstract":false,"args":[{"name":"x","doc":null,"default_value":"","external_name":"x","restriction":""},{"name":"y","doc":null,"default_value":"","external_name":"y","restriction":""}],"args_string":"(x, y)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L131","def":{"name":"vstack","args":[{"name":"x","doc":null,"default_value":"","external_name":"x","restriction":""},{"name":"y","doc":null,"default_value":"","external_name":"y","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":""}},{"id":"zero(row_count,column_count=row_count)-class-method","html_id":"zero(row_count,column_count=row_count)-class-method","name":"zero","doc":"Creates a zero matrix.","summary":"

Creates a zero matrix.

","abstract":false,"args":[{"name":"row_count","doc":null,"default_value":"","external_name":"row_count","restriction":""},{"name":"column_count","doc":null,"default_value":"row_count","external_name":"column_count","restriction":""}],"args_string":"(row_count, column_count = row_count)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L135","def":{"name":"zero","args":[{"name":"row_count","doc":null,"default_value":"","external_name":"row_count","restriction":""},{"name":"column_count","doc":null,"default_value":"row_count","external_name":"column_count","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"rows = Array.new(row_count) do\n Vector.new(column_count)\nend\nMatrix.new(rows, column_count)\n"}}],"constructors":[{"id":"new(rows,column_count:Int32?=nil)-class-method","html_id":"new(rows,column_count:Int32?=nil)-class-method","name":"new","doc":null,"summary":null,"abstract":false,"args":[{"name":"rows","doc":null,"default_value":"","external_name":"rows","restriction":""},{"name":"column_count","doc":null,"default_value":"nil","external_name":"column_count","restriction":"Int32 | ::Nil"}],"args_string":"(rows, column_count : Int32? = nil)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L15","def":{"name":"new","args":[{"name":"rows","doc":null,"default_value":"","external_name":"rows","restriction":""},{"name":"column_count","doc":null,"default_value":"nil","external_name":"column_count","restriction":"Int32 | ::Nil"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"_ = allocate\n_.initialize(rows, column_count)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"id":"*(other:Matrix)-instance-method","html_id":"*(other:Matrix)-instance-method","name":"*","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"args_string":"(other : Matrix)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L140","def":{"name":"*","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if column_count != other.column_count\n raise(\"Dimension mismatch\")\nend\nrows = Array.new(row_count) do |i|\n Vector.new(other.column_count) do |j|\n (0...column_count).reduce(0.0) do |vij, k|\n vij + (self[i, k] * other[k, j])\n end\n end\nend\nreturn Matrix.new(rows, other.column_count)\n"}},{"id":"*(int:Int)-instance-method","html_id":"*(int:Int)-instance-method","name":"*","doc":null,"summary":null,"abstract":false,"args":[{"name":"int","doc":null,"default_value":"","external_name":"int","restriction":"Int"}],"args_string":"(int : Int)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L154","def":{"name":"*","args":[{"name":"int","doc":null,"default_value":"","external_name":"int","restriction":"Int"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"rows = self.rows.map do |row|\n row.map do |e|\n e * int\n end\nend\nMatrix.new(rows, column_count)\n"}},{"id":"*(ind:Indexable)-instance-method","html_id":"*(ind:Indexable)-instance-method","name":"*","doc":null,"summary":null,"abstract":false,"args":[{"name":"ind","doc":null,"default_value":"","external_name":"ind","restriction":"Indexable"}],"args_string":"(ind : Indexable)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L161","def":{"name":"*","args":[{"name":"ind","doc":null,"default_value":"","external_name":"ind","restriction":"Indexable"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"m = column_vector\nr = self * m\nr.column(0)\n"}},{"id":"**(int)-instance-method","html_id":"**(int)-instance-method","name":"**","doc":null,"summary":null,"abstract":false,"args":[{"name":"int","doc":null,"default_value":"","external_name":"int","restriction":""}],"args_string":"(int)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L167","def":{"name":"**","args":[{"name":"int","doc":null,"default_value":"","external_name":"int","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if int >= 1\nelse\n raise(\"Number can not the less than 1\")\nend\nmat = self\n(int - 1).times do\n mat = mat * self\nend\nmat\n"}},{"id":"+(other:Matrix)-instance-method","html_id":"+(other:Matrix)-instance-method","name":"+","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"args_string":"(other : Matrix)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L176","def":{"name":"+","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if column_count != other.column_count\n raise(\"Dimension mismatch\")\nend\nrows = Array.new(row_count) do |i|\n Vector.new(other.column_count) do |j|\n self[i, j] + other[i, j]\n end\nend\nreturn Matrix.new(rows, other.column_count)\n"}},{"id":"+(vec:Indexable)-instance-method","html_id":"+(vec:Indexable)-instance-method","name":"+","doc":null,"summary":null,"abstract":false,"args":[{"name":"vec","doc":null,"default_value":"","external_name":"vec","restriction":"Indexable"}],"args_string":"(vec : Indexable)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L188","def":{"name":"+","args":[{"name":"vec","doc":null,"default_value":"","external_name":"vec","restriction":"Indexable"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"vec = vec.is_a?(Vector) ? vec : Vector.create(vec)\nself + (column_vector(vec))\n"}},{"id":"-(vec:Indexable)-instance-method","html_id":"-(vec:Indexable)-instance-method","name":"-","doc":null,"summary":null,"abstract":false,"args":[{"name":"vec","doc":null,"default_value":"","external_name":"vec","restriction":"Indexable"}],"args_string":"(vec : Indexable)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L205","def":{"name":"-","args":[{"name":"vec","doc":null,"default_value":"","external_name":"vec","restriction":"Indexable"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"vec = vec.is_a?(Vector) ? vec : Vector.create(vec)\nself + (column_vector(vec))\n"}},{"id":"-(other:Matrix)-instance-method","html_id":"-(other:Matrix)-instance-method","name":"-","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"args_string":"(other : Matrix)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L193","def":{"name":"-","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if column_count != other.column_count\n raise(\"Dimension mismatch\")\nend\nrows = Array.new(row_count) do |i|\n Vector.new(other.column_count) do |j|\n self[i, j] - other[i, j]\n end\nend\nreturn Matrix.new(rows, other.column_count)\n"}},{"id":"/(other:Matrix)-instance-method","html_id":"/(other:Matrix)-instance-method","name":"/","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"args_string":"(other : Matrix)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L210","def":{"name":"/","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"self * other.inverse"}},{"id":"/(vec:Indexable)-instance-method","html_id":"/(vec:Indexable)-instance-method","name":"/","doc":null,"summary":null,"abstract":false,"args":[{"name":"vec","doc":null,"default_value":"","external_name":"vec","restriction":"Indexable"}],"args_string":"(vec : Indexable)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L214","def":{"name":"/","args":[{"name":"vec","doc":null,"default_value":"","external_name":"vec","restriction":"Indexable"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"rows = self.rows.map do |row|\n row.map do |e|\n e / other\n end\nend\nreturn new_matrix(rows, column_count)\n"}},{"id":"==(other:Matrix)-instance-method","html_id":"==(other:Matrix)-instance-method","name":"==","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"args_string":"(other : Matrix)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L221","def":{"name":"==","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if (Matrix === other) && (column_count == other.column_count)\nelse\n return false\nend\nrows == other.rows\n"}},{"id":"[](row:Int,col:Int)-instance-method","html_id":"[](row:Int,col:Int)-instance-method","name":"[]","doc":"Returns element `(row, col)` of the matrix. Throws error on index error.","summary":"

Returns element (row, col) of the matrix.

","abstract":false,"args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":"Int"},{"name":"col","doc":null,"default_value":"","external_name":"col","restriction":"Int"}],"args_string":"(row : Int, col : Int)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L228","def":{"name":"[]","args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":"Int"},{"name":"col","doc":null,"default_value":"","external_name":"col","restriction":"Int"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"self[row][col]"}},{"id":"[]?(row:Int,col:Int)-instance-method","html_id":"[]?(row:Int,col:Int)-instance-method","name":"[]?","doc":"Returns element `(row, col)` of the matrix, or nil if the index is not found.","summary":"

Returns element (row, col) of the matrix, or nil if the index is not found.

","abstract":false,"args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":"Int"},{"name":"col","doc":null,"default_value":"","external_name":"col","restriction":"Int"}],"args_string":"(row : Int, col : Int)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L233","def":{"name":"[]?","args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":"Int"},{"name":"col","doc":null,"default_value":"","external_name":"col","restriction":"Int"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"v = fetch(row) do\n nil\nend\nif v.nil?\nelse\n v[col]?\nend\n"}},{"id":"adjugate-instance-method","html_id":"adjugate-instance-method","name":"adjugate","doc":"Returns the adjugate of the matrix.","summary":"

Returns the adjugate of the matrix.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L239","def":{"name":"adjugate","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if square?\nelse\n raise(\"Dimention mismatch: `Matrix#adjugate` requires a square matrix.\")\nend\nMatrix.build(row_count, column_count) do |row, column|\n cofactor(column, row)\nend\n"}},{"id":"cofactor(row,column)-instance-method","html_id":"cofactor(row,column)-instance-method","name":"cofactor","doc":"Returns the (row, column) cofactor which is obtained by multiplying the first minor by (-1)**(row + column)","summary":"

Returns the (row, column) cofactor which is obtained by multiplying the first minor by (-1)**(row + column)

","abstract":false,"args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":""},{"name":"column","doc":null,"default_value":"","external_name":"column","restriction":""}],"args_string":"(row, column)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L247","def":{"name":"cofactor","args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":""},{"name":"column","doc":null,"default_value":"","external_name":"column","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if empty?\n raise(\"cofactor of empty matrix is not defined\")\nend\nif square?\nelse\n raise(\"Dimention mismatch: `Matrix#cofactor` requires a square matrix.\")\nend\ndet_of_minor = (first_minor(row, column)).determinant\ndet_of_minor * ((-1.0) ** (row + column))\n"}},{"id":"column(j,&block)-instance-method","html_id":"column(j,&block)-instance-method","name":"column","doc":"Iterates over the specified column in the matrix, returning the Vector's items.","summary":"

Iterates over the specified column in the matrix, returning the Vector's items.

","abstract":false,"args":[{"name":"j","doc":null,"default_value":"","external_name":"j","restriction":""}],"args_string":"(j, &block)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L274","def":{"name":"column","args":[{"name":"j","doc":null,"default_value":"","external_name":"j","restriction":""}],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"if j >= column_count || j < (-column_count)\n return self\nend\nrow_count.times do |i|\n yield rows[i][j]\nend\nself\n"}},{"id":"column(j)-instance-method","html_id":"column(j)-instance-method","name":"column","doc":"Returns column vector number `j` of the matrix as a `Vector` (starting at 0 like an array).","summary":"

Returns column vector number j of the matrix as a Vector (starting at 0 like an array).

","abstract":false,"args":[{"name":"j","doc":null,"default_value":"","external_name":"j","restriction":""}],"args_string":"(j)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L265","def":{"name":"column","args":[{"name":"j","doc":null,"default_value":"","external_name":"j","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if j >= column_count || j < (-column_count)\n raise(\"Index out of range\")\nend\ncol = Array(Float64).new(row_count) do |i|\n rows[i][j]\nend\nVector.create(col)\n"}},{"id":"column?(j)-instance-method","html_id":"column?(j)-instance-method","name":"column?","doc":"Returns column vector number `j` of the matrix as a `Vector` (starting at 0 like an array).","summary":"

Returns column vector number j of the matrix as a Vector (starting at 0 like an array).

","abstract":false,"args":[{"name":"j","doc":null,"default_value":"","external_name":"j","restriction":""}],"args_string":"(j)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L256","def":{"name":"column?","args":[{"name":"j","doc":null,"default_value":"","external_name":"j","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if j >= column_count || j < (-column_count)\n return nil\nend\ncol = Array(Float64).new(row_count) do |i|\n rows[i][j]\nend\nVector.create(col)\n"}},{"id":"column_count:Int32-instance-method","html_id":"column_count:Int32-instance-method","name":"column_count","doc":null,"summary":null,"abstract":false,"args":[],"args_string":" : Int32","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L11","def":{"name":"column_count","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Int32","visibility":"Public","body":"@column_count"}},{"id":"column_vectors-instance-method","html_id":"column_vectors-instance-method","name":"column_vectors","doc":"Returns an array of the column vectors of the matrix. See `Vector`.","summary":"

Returns an array of the column vectors of the matrix.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L283","def":{"name":"column_vectors","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Array(Vector).new(column_count) do |i|\n column(i)\nend"}},{"id":"determinant-instance-method","html_id":"determinant-instance-method","name":"determinant","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L354","def":{"name":"determinant","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if square?\nelse\n raise(\"Dimention mismatch: `Matrix#determinant` requires a square matrix.\")\nend\nm = rows\ncase row_count\nwhen 0\n +1\nwhen 1\n +m[0][0]\nwhen 2\n ((+m[0][0]) * m[1][1]) - (m[0][1] * m[1][0])\nwhen 3\n m0, m1, m2 = m\n (((((((+m0[0]) * m1[1]) * m2[2]) - ((m0[0] * m1[2]) * m2[1])) - ((m0[1] * m1[0]) * m2[2])) + ((m0[1] * m1[2]) * m2[0])) + ((m0[2] * m1[0]) * m2[1])) - ((m0[2] * m1[1]) * m2[0])\nwhen 4\n m0, m1, m2, m3 = m\n ((((((((((((((((((((((((((+m0[0]) * m1[1]) * m2[2]) * m3[3]) - (((m0[0] * m1[1]) * m2[3]) * m3[2])) - (((m0[0] * m1[2]) * m2[1]) * m3[3])) + (((m0[0] * m1[2]) * m2[3]) * m3[1])) + (((m0[0] * m1[3]) * m2[1]) * m3[2])) - (((m0[0] * m1[3]) * m2[2]) * m3[1])) - (((m0[1] * m1[0]) * m2[2]) * m3[3])) + (((m0[1] * m1[0]) * m2[3]) * m3[2])) + (((m0[1] * m1[2]) * m2[0]) * m3[3])) - (((m0[1] * m1[2]) * m2[3]) * m3[0])) - (((m0[1] * m1[3]) * m2[0]) * m3[2])) + (((m0[1] * m1[3]) * m2[2]) * m3[0])) + (((m0[2] * m1[0]) * m2[1]) * m3[3])) - (((m0[2] * m1[0]) * m2[3]) * m3[1])) - (((m0[2] * m1[1]) * m2[0]) * m3[3])) + (((m0[2] * m1[1]) * m2[3]) * m3[0])) + (((m0[2] * m1[3]) * m2[0]) * m3[1])) - (((m0[2] * m1[3]) * m2[1]) * m3[0])) - (((m0[3] * m1[0]) * m2[1]) * m3[2])) + (((m0[3] * m1[0]) * m2[2]) * m3[1])) + (((m0[3] * m1[1]) * m2[0]) * m3[2])) - (((m0[3] * m1[1]) * m2[2]) * m3[0])) - (((m0[3] * m1[2]) * m2[0]) * m3[1])) + (((m0[3] * m1[2]) * m2[1]) * m3[0])\nelse\n determinant_bareiss\nend\n"}},{"id":"first_minor(row,column)-instance-method","html_id":"first_minor(row,column)-instance-method","name":"first_minor","doc":null,"summary":null,"abstract":false,"args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":""},{"name":"column","doc":null,"default_value":"","external_name":"column","restriction":""}],"args_string":"(row, column)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L429","def":{"name":"first_minor","args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":""},{"name":"column","doc":null,"default_value":"","external_name":"column","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if empty?\n raise(\"first_minor of empty matrix is not defined\")\nend\nif 0 <= row && row < row_count\nelse\n raise(ArgumentError.new(\"invalid row (#{row.inspect} for 0..#{row_count - 1})\"))\nend\nif 0 <= column && column < column_count\nelse\n raise(ArgumentError.new(\"invalid column (#{column.inspect} for 0..#{column_count - 1})\"))\nend\narrays = to_a.map(&.to_a)\narrays.delete_at(row)\narrays.each do |array|\n array.delete_at(column)\nend\nMatrix.new(arrays, column_count - 1)\n"}},{"id":"inverse-instance-method","html_id":"inverse-instance-method","name":"inverse","doc":"Returns the inverse of the matrix.","summary":"

Returns the inverse of the matrix.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L304","def":{"name":"inverse","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if square?\nelse\n if square?\n else\n raise(\"Dimention mismatch: `Matrix#inverse` requires a square matrix.\")\n end\nend\n(Matrix.identity(row_count)).inverse_from(self)\n"}},{"id":"laplace_expansion(*,row=nil,column=nil)-instance-method","html_id":"laplace_expansion(*,row=nil,column=nil)-instance-method","name":"laplace_expansion","doc":"Returns the Laplace expansion along given row or column.","summary":"

Returns the Laplace expansion along given row or column.

","abstract":false,"args":[{"name":"","doc":null,"default_value":"","external_name":"","restriction":""},{"name":"row","doc":null,"default_value":"nil","external_name":"row","restriction":""},{"name":"column","doc":null,"default_value":"nil","external_name":"column","restriction":""}],"args_string":"(*, row = nil, column = nil)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L450","def":{"name":"laplace_expansion","args":[{"name":"","doc":null,"default_value":"","external_name":"","restriction":""},{"name":"row","doc":null,"default_value":"nil","external_name":"row","restriction":""},{"name":"column","doc":null,"default_value":"nil","external_name":"column","restriction":""}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"num = row || column\nif (!num) || (row && column)\n raise(ArgumentError.new(\"exactly one the row or column arguments must be specified\"))\nend\nif square?\nelse\n raise(\"Dimention mismatch: `Matrix#determinant` requires a square matrix.\")\nend\nif empty?\n raise(\"laplace_expansion of empty matrix is not defined\")\nend\nif 0 <= num && num < row_count\nelse\n raise(ArgumentError.new(\"invalid num (#{num.inspect} for 0..#{row_count - 1})\"))\nend\nif row\n (row(num)).map_with_index do |e, k|\n e * (cofactor(num, k))\n end.reduce(&.+)\nelse\n (column(num)).map_with_index do |e, k|\n e * (cofactor(k, num))\n end.reduce(&.+)\nend\n"}},{"id":"pretty_print(pp):Nil-instance-method","html_id":"pretty_print(pp):Nil-instance-method","name":"pretty_print","doc":null,"summary":null,"abstract":false,"args":[{"name":"pp","doc":null,"default_value":"","external_name":"pp","restriction":""}],"args_string":"(pp) : Nil","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L516","def":{"name":"pretty_print","args":[{"name":"pp","doc":null,"default_value":"","external_name":"pp","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Nil","visibility":"Public","body":"pp.list(\"[\", self, \"]\") do |vec|\n pp.group do\n vec.to_a.pretty_print(pp)\n end\nend"}},{"id":"row(i,&block)-instance-method","html_id":"row(i,&block)-instance-method","name":"row","doc":null,"summary":null,"abstract":false,"args":[{"name":"i","doc":null,"default_value":"","external_name":"i","restriction":""}],"args_string":"(i, &block)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L475","def":{"name":"row","args":[{"name":"i","doc":null,"default_value":"","external_name":"i","restriction":""}],"double_splat":null,"splat_index":null,"yields":0,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":""},"return_type":"","visibility":"Public","body":"(@rows.fetch(i) do\n return self\nend).each(&block)\nself\n"}},{"id":"row(i)-instance-method","html_id":"row(i)-instance-method","name":"row","doc":null,"summary":null,"abstract":false,"args":[{"name":"i","doc":null,"default_value":"","external_name":"i","restriction":""}],"args_string":"(i)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L480","def":{"name":"row","args":[{"name":"i","doc":null,"default_value":"","external_name":"i","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.create(rows.fetch(i) do\n [] of Float64\nend)"}},{"id":"row_count:Int32-instance-method","html_id":"row_count:Int32-instance-method","name":"row_count","doc":null,"summary":null,"abstract":false,"args":[],"args_string":" : Int32","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L13","def":{"name":"row_count","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Int32","visibility":"Public","body":"@row_count"}},{"id":"rows-instance-method","html_id":"rows-instance-method","name":"rows","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L484","def":{"name":"rows","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"rows = [] of Vector\nrow_count.times do |i|\n rows << self[i - 1]\nend\nrows\n"}},{"id":"square?-instance-method","html_id":"square?-instance-method","name":"square?","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L492","def":{"name":"square?","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"row_count == column_count"}},{"id":"to_s(io)-instance-method","html_id":"to_s(io)-instance-method","name":"to_s","doc":null,"summary":null,"abstract":false,"args":[{"name":"io","doc":null,"default_value":"","external_name":"io","restriction":""}],"args_string":"(io)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L502","def":{"name":"to_s","args":[{"name":"io","doc":null,"default_value":"","external_name":"io","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if empty?\n \"Matrix.empty(#{row_count}, #{column_count})\"\nelse\n io << \"Matrix[\"\n io << (map do |row|\n (\"{\" + (row.to_a.map do |e|\n e.to_s\n end.join(\", \"))) + \"}\"\n end.join(\", \"))\n io << \"]\"\nend"}},{"id":"transpose-instance-method","html_id":"transpose-instance-method","name":"transpose","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L496","def":{"name":"transpose","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if row_count.zero?\n return Matrix.empty(column_count, 0)\nend\ntransposed = rows.map do |v|\n v.to_a\nend.transpose\nMatrix.new(transposed, row_count)\n"}},{"id":"unsafe_fetch(index:Int)-instance-method","html_id":"unsafe_fetch(index:Int)-instance-method","name":"unsafe_fetch","doc":null,"summary":null,"abstract":false,"args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"}],"args_string":"(index : Int)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L525","def":{"name":"unsafe_fetch","args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@buffer[index]"}}],"macros":[],"types":[]},{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra/NDArray","path":"Apatite/LinearAlgebra/NDArray.html","kind":"class","full_name":"Apatite::LinearAlgebra::NDArray","name":"NDArray","abstract":false,"superclass":{"html_id":"github.com/watzon/apatite/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"github.com/watzon/apatite/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"github.com/watzon/apatite/Indexable","kind":"module","full_name":"Indexable","name":"Indexable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Iterable","kind":"module","full_name":"Iterable","name":"Iterable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"github.com/watzon/apatite/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"apatite/linear_algebra/ndarray.cr","line_number":2,"url":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/ndarray.cr"}],"repository_name":"github.com/watzon/apatite","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[{"html_id":"github.com/watzon/apatite/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Indexable","kind":"module","full_name":"Indexable","name":"Indexable"}],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra","kind":"module","full_name":"Apatite::LinearAlgebra","name":"LinearAlgebra"},"doc":null,"summary":null,"class_methods":[],"constructors":[{"id":"new(data:Array(Number),shape:Array(Int32)?=nil)-class-method","html_id":"new(data:Array(Number),shape:Array(Int32)?=nil)-class-method","name":"new","doc":null,"summary":null,"abstract":false,"args":[{"name":"data","doc":null,"default_value":"","external_name":"data","restriction":"Array(Number)"},{"name":"shape","doc":null,"default_value":"nil","external_name":"shape","restriction":"Array(Int32) | ::Nil"}],"args_string":"(data : Array(Number), shape : Array(Int32)? = nil)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/ndarray.cr#L18","def":{"name":"new","args":[{"name":"data","doc":null,"default_value":"","external_name":"data","restriction":"Array(Number)"},{"name":"shape","doc":null,"default_value":"nil","external_name":"shape","restriction":"Array(Int32) | ::Nil"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"_ = allocate\n_.initialize(data, shape)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"id":"[](*args,**options)-instance-method","html_id":"[](*args,**options)-instance-method","name":"[]","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/ndarray.cr#L11","def":{"name":"[]","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@data[*args, **options]"}},{"id":"[](*args,**options,&block)-instance-method","html_id":"[](*args,**options,&block)-instance-method","name":"[]","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options, &block)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/ndarray.cr#L11","def":{"name":"[]","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"@data[*args, **options] do |*yield_args|\n yield *yield_args\nend"}},{"id":"[]=(*args,**options)-instance-method","html_id":"[]=(*args,**options)-instance-method","name":"[]=","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/ndarray.cr#L13","def":{"name":"[]=","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@data[*args] = **options"}},{"id":"[]?(*args,**options)-instance-method","html_id":"[]?(*args,**options)-instance-method","name":"[]?","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/ndarray.cr#L12","def":{"name":"[]?","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@data[*args, **options]?"}},{"id":"[]?(*args,**options,&block)-instance-method","html_id":"[]?(*args,**options,&block)-instance-method","name":"[]?","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options, &block)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/ndarray.cr#L12","def":{"name":"[]?","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"@data[*args, **options]? do |*yield_args|\n yield *yield_args\nend"}},{"id":"abs-instance-method","html_id":"abs-instance-method","name":"abs","doc":"Returns the absolute value of every item in the array","summary":"

Returns the absolute value of every item in the array

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/ndarray.cr#L24","def":{"name":"abs","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"map do |e|\n e.abs\nend"}},{"id":"acos-instance-method","html_id":"acos-instance-method","name":"acos","doc":"Returns the arccosine of each element in the current array.","summary":"

Returns the arccosine of each element in the current array.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/ndarray.cr#L29","def":{"name":"acos","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":""}},{"id":"data:Array(Float64)-instance-method","html_id":"data:Array(Float64)-instance-method","name":"data","doc":null,"summary":null,"abstract":false,"args":[],"args_string":" : Array(Float64)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/ndarray.cr#L9","def":{"name":"data","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Array(Float64)","visibility":"Public","body":"@data"}},{"id":"shape:Array(Int32)-instance-method","html_id":"shape:Array(Int32)-instance-method","name":"shape","doc":null,"summary":null,"abstract":false,"args":[],"args_string":" : Array(Int32)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/ndarray.cr#L11","def":{"name":"shape","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Array(Int32)","visibility":"Public","body":"@shape"}},{"id":"size(*args,**options)-instance-method","html_id":"size(*args,**options)-instance-method","name":"size","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/ndarray.cr#L16","def":{"name":"size","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@data.size(*args, **options)"}},{"id":"size(*args,**options,&block)-instance-method","html_id":"size(*args,**options,&block)-instance-method","name":"size","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options, &block)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/ndarray.cr#L16","def":{"name":"size","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"@data.size(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"id":"to_unsafe(*args,**options)-instance-method","html_id":"to_unsafe(*args,**options)-instance-method","name":"to_unsafe","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/ndarray.cr#L15","def":{"name":"to_unsafe","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@data.to_unsafe(*args, **options)"}},{"id":"to_unsafe(*args,**options,&block)-instance-method","html_id":"to_unsafe(*args,**options,&block)-instance-method","name":"to_unsafe","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options, &block)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/ndarray.cr#L15","def":{"name":"to_unsafe","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"@data.to_unsafe(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"id":"unsafe_fetch(*args,**options)-instance-method","html_id":"unsafe_fetch(*args,**options)-instance-method","name":"unsafe_fetch","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/ndarray.cr#L14","def":{"name":"unsafe_fetch","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@data.unsafe_fetch(*args, **options)"}},{"id":"unsafe_fetch(*args,**options,&block)-instance-method","html_id":"unsafe_fetch(*args,**options,&block)-instance-method","name":"unsafe_fetch","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options, &block)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/ndarray.cr#L14","def":{"name":"unsafe_fetch","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"@data.unsafe_fetch(*args, **options) do |*yield_args|\n yield *yield_args\nend"}}],"macros":[],"types":[]},{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra/Vector","path":"Apatite/LinearAlgebra/Vector.html","kind":"class","full_name":"Apatite::LinearAlgebra::Vector","name":"Vector","abstract":false,"superclass":{"html_id":"github.com/watzon/apatite/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"github.com/watzon/apatite/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"github.com/watzon/apatite/Indexable","kind":"module","full_name":"Indexable","name":"Indexable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Iterable","kind":"module","full_name":"Iterable","name":"Iterable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"github.com/watzon/apatite/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"apatite/linear_algebra/vector.cr","line_number":4,"url":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr"}],"repository_name":"github.com/watzon/apatite","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[{"id":"I","name":"I","value":"Vector.create([1.0, 0.0, 0.0])","doc":"Cartesian unit vector I","summary":"

Cartesian unit vector I

"},{"id":"J","name":"J","value":"Vector.create([0.0, 1.0, 0.0])","doc":"Cartesian unit vector J","summary":"

Cartesian unit vector J

"},{"id":"K","name":"K","value":"Vector.create([0.0, 0.0, 1.0])","doc":"Cartesian unit vector K","summary":"

Cartesian unit vector K

"}],"included_modules":[{"html_id":"github.com/watzon/apatite/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Indexable","kind":"module","full_name":"Indexable","name":"Indexable"}],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra","kind":"module","full_name":"Apatite::LinearAlgebra","name":"LinearAlgebra"},"doc":"Represents a mathematical vector, and also constitutes a row or column\nof a `Matrix`","summary":"

Represents a mathematical vector, and also constitutes a row or column of a Matrix

","class_methods":[{"id":"[](*array)-class-method","html_id":"[](*array)-class-method","name":"[]","doc":null,"summary":null,"abstract":false,"args":[{"name":"array","doc":null,"default_value":"","external_name":"array","restriction":""}],"args_string":"(*array)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L156","def":{"name":"[]","args":[{"name":"array","doc":null,"default_value":"","external_name":"array","restriction":""}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.create(array)"}},{"id":"basis(size,index)-class-method","html_id":"basis(size,index)-class-method","name":"basis","doc":"Returns a standard basis n-vector.","summary":"

Returns a standard basis n-vector.

","abstract":false,"args":[{"name":"size","doc":null,"default_value":"","external_name":"size","restriction":""},{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":""}],"args_string":"(size, index)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L138","def":{"name":"basis","args":[{"name":"size","doc":null,"default_value":"","external_name":"size","restriction":""},{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if size < 1\n raise(ArgumentError.new(\"invalid size (#{size} for 1..)\"))\nend\nif 0 <= index && index < size\nelse\n raise(ArgumentError.new(\"invalid index (#{index} for 0...#{size})\"))\nend\nvec = Vector.new(size, 0.0)\nvec[index] = 1.0\nvec\n"}},{"id":"create(elements:Indexable(Number))-class-method","html_id":"create(elements:Indexable(Number))-class-method","name":"create","doc":"Creates a new `Vector` from the elements of another `Indexable`\ncollection.\n\n```\nVector.create([1, 2, 3]) # Vector{1.0, 2.0, 3.0}\n```","summary":"

Creates a new Vector from the elements of another Indexable collection.

","abstract":false,"args":[{"name":"elements","doc":null,"default_value":"","external_name":"elements","restriction":"Indexable(Number)"}],"args_string":"(elements : Indexable(Number))","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L118","def":{"name":"create","args":[{"name":"elements","doc":null,"default_value":"","external_name":"elements","restriction":"Indexable(Number)"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"vec = Vector.new\nelements.each do |el|\n vec.push(el.to_f64)\nend\nvec\n"}},{"id":"ones(n)-class-method","html_id":"ones(n)-class-method","name":"ones","doc":"Create a new vector of size `n` filled with ones.","summary":"

Create a new vector of size n filled with ones.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L152","def":{"name":"ones","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.new(n, 1.0)"}},{"id":"random(n,range=nil)-class-method","html_id":"random(n,range=nil)-class-method","name":"random","doc":"Creates a new `Vector` of size `n` filled with random numbers. A `range`\ncan optionally be passed in if you want to limit the random numbers\nto a given range.","summary":"

Creates a new Vector of size n filled with random numbers.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""},{"name":"range","doc":null,"default_value":"nil","external_name":"range","restriction":""}],"args_string":"(n, range = nil)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L129","def":{"name":"random","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""},{"name":"range","doc":null,"default_value":"nil","external_name":"range","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"vec = Vector.new(n)\nn.times do\n vec.push(rand((range || -1e+1)..1e+1))\nend\nvec\n"}},{"id":"zeros(n)-class-method","html_id":"zeros(n)-class-method","name":"zeros","doc":"Create a new vector of size `n` filled with zeros.","summary":"

Create a new vector of size n filled with zeros.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L147","def":{"name":"zeros","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.new(n, 0.0)"}}],"constructors":[{"id":"build(capacity:Int,&block):self-class-method","html_id":"build(capacity:Int,&block):self-class-method","name":"build","doc":"Creates a new `Vector`, allocating an internal buffer with the given *capacity*,\nand yielding that buffer. The given block must return the desired size of the vector.\n\nThis method is **unsafe**.\n\n```\nVector.build(3) do |buffer|\n LibSome.fill_buffer_and_return_number_of_elements_filled(buffer)\nend\n```","summary":"

Creates a new Vector, allocating an internal buffer with the given capacity, and yielding that buffer.

","abstract":false,"args":[{"name":"capacity","doc":null,"default_value":"","external_name":"capacity","restriction":"Int"}],"args_string":"(capacity : Int, &block) : self","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L106","def":{"name":"build","args":[{"name":"capacity","doc":null,"default_value":"","external_name":"capacity","restriction":"Int"}],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"self","visibility":"Public","body":"vec = Vector.new(capacity)\nvec.size = (yield vec.to_unsafe).to_i\nvec\n"}},{"id":"new(size:Int,value:Float64)-class-method","html_id":"new(size:Int,value:Float64)-class-method","name":"new","doc":"Creates a new `Vector` of the given *size* filled with the same *value* in each position.\n\n```\nVector.new(3, 1.0) # => Vector{1.0, 1.0, 1.0}\n```","summary":"

Creates a new Vector of the given size filled with the same value in each position.

","abstract":false,"args":[{"name":"size","doc":null,"default_value":"","external_name":"size","restriction":"Int"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":"Float64"}],"args_string":"(size : Int, value : Float64)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L63","def":{"name":"new","args":[{"name":"size","doc":null,"default_value":"","external_name":"size","restriction":"Int"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":"Float64"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"_ = allocate\n_.initialize(size, value)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"id":"new(initial_capacity:Int)-class-method","html_id":"new(initial_capacity:Int)-class-method","name":"new","doc":"Creates a new empty `Vector` backed by a buffer that is initially\n`initial_capacity` big.\n\nThe *initial_capacity* is useful to avoid unnecessary reallocations\nof the internal buffer in case of growth. If you have an estimate\nof the maximum number of elements an vector will hold, the vector should\nbe initialized with that capacity for improved performance.\n\n```\nvec = Vector.new(5)\nvec.size # => 0\n```","summary":"

Creates a new empty Vector backed by a buffer that is initially initial_capacity big.

","abstract":false,"args":[{"name":"initial_capacity","doc":null,"default_value":"","external_name":"initial_capacity","restriction":"Int"}],"args_string":"(initial_capacity : Int)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L43","def":{"name":"new","args":[{"name":"initial_capacity","doc":null,"default_value":"","external_name":"initial_capacity","restriction":"Int"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"_ = allocate\n_.initialize(initial_capacity)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"id":"new-class-method","html_id":"new-class-method","name":"new","doc":"Create a new empty `Vector`.","summary":"

Create a new empty Vector.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L25","def":{"name":"new","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"_ = allocate\n_.initialize\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"id":"new(size:Int,&block:Int32->Float64)-class-method","html_id":"new(size:Int,&block:Int32->Float64)-class-method","name":"new","doc":"Creates a new `Vector` of the given *size* and invokes the given block once\nfor each index of `self`, assigning the block's value in that index.\n\n```\nVector.new(3) { |i| (i + 1.0) ** 2.0 } # => Vector{1.0, 4.0, 9.0}\n\nvec = Vector.new(3) { 5.0 }\nvec # => Vector{5.0, 5.0, 5.0}\n```","summary":"

Creates a new Vector of the given size and invokes the given block once for each index of self, assigning the block's value in that index.

","abstract":false,"args":[{"name":"size","doc":null,"default_value":"","external_name":"size","restriction":"Int"}],"args_string":"(size : Int, &block : Int32 -> Float64)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L87","def":{"name":"new","args":[{"name":"size","doc":null,"default_value":"","external_name":"size","restriction":"Int"}],"double_splat":null,"splat_index":null,"yields":1,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":"(Int32 -> Float64)"},"return_type":"","visibility":"Public","body":"Vector.build(size) do |buffer|\n size.to_i.times do |i|\n buffer[i] = yield i\n end\n size\nend"}}],"instance_methods":[{"id":"*(other)-instance-method","html_id":"*(other)-instance-method","name":"*","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"args_string":"(other)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L370","def":{"name":"*","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"multiply(other)"}},{"id":"+(other)-instance-method","html_id":"+(other)-instance-method","name":"+","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"args_string":"(other)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L362","def":{"name":"+","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"add(other)"}},{"id":"-(other)-instance-method","html_id":"-(other)-instance-method","name":"-","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"args_string":"(other)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L366","def":{"name":"-","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"subtract(other)"}},{"id":"<<(value:Float64)-instance-method","html_id":"<<(value:Float64)-instance-method","name":"<<","doc":"Alias for `#push`","summary":"

Alias for #push

","abstract":false,"args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":"Float64"}],"args_string":"(value : Float64)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L349","def":{"name":"<<","args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":"Float64"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"push(value)"}},{"id":"(other)-instance-method","html_id":"(other)-instance-method","name":"<=>","doc":"Combined comparison operator. Returns *0* if `self` equals *other*, *1* if\n`self` is greater than *other* and *-1* if `self` is smaller than *other*.\n\nIt compares the elements of both vectors in the same position using the\n`<=>` operator. As soon as one of such comparisons returns a non-zero\nvalue, that result is the return value of the comparison.\n\nIf all elements are equal, the comparison is based on the size of the vectors.\n\n```\nVector{8.0} <=> Vector(1.0, 2.0, 3.0} # => 1\nVector{2.0} <=> Vector{4.0, 2.0, 3.0} # => -1\nVector{1.0, 2.0} <=> Vector{1.0, 2.0} # => 0\n```","summary":"

Combined comparison operator.

","abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"args_string":"(other)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L339","def":{"name":"<=>","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"min_size = Math.min(size, other.size)\n0.upto(min_size - 1) do |i|\n n = @buffer[i] <=> other.to_unsafe[i]\n if n != 0\n return n\n end\nend\nsize <=> other.size\n"}},{"id":"==(other:Vector)-instance-method","html_id":"==(other:Vector)-instance-method","name":"==","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Vector"}],"args_string":"(other : Vector)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L353","def":{"name":"==","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Vector"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"equals?(other) do |x, y|\n x == y\nend"}},{"id":"[](start:Int,count:Int)-instance-method","html_id":"[](start:Int,count:Int)-instance-method","name":"[]","doc":"Returns count or less (if there aren't enough) elements starting at the\ngiven start index.\n\nNegative indices count backward from the end of the vector (-1 is the last\nelement). Additionally, an empty vector is returned when the starting index\nfor an element range is at the end of the vector.\n\nRaises `IndexError` if the starting index is out of range.\n\n```\nv = Vector{1.0, 2.0, 3.0, 4.0, 5.0}\nv[1, 3] # => Vector{2.0, 3.0, 4.0}\nv[6, 10] # raise IndexError\n```","summary":"

Returns count or less (if there aren't enough) elements starting at the given start index.

","abstract":false,"args":[{"name":"start","doc":null,"default_value":"","external_name":"start","restriction":"Int"},{"name":"count","doc":null,"default_value":"","external_name":"count","restriction":"Int"}],"args_string":"(start : Int, count : Int)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L191","def":{"name":"[]","args":[{"name":"start","doc":null,"default_value":"","external_name":"start","restriction":"Int"},{"name":"count","doc":null,"default_value":"","external_name":"count","restriction":"Int"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if count < 0\n raise(ArgumentError.new(\"Negative count: #{count}\"))\nend\nif start == size\n return Vector.new\nend\nif start < 0\n start = start + size\nend\nif 0 <= start && start <= size\nelse\n raise(IndexError.new)\nend\nif count == 0\n return Vector.new\nend\ncount = Math.min(count, size - start)\nVector.build(count) do |buffer|\n buffer.copy_from(@buffer + start, count)\n count\nend\n"}},{"id":"[](range:Range(Int,Int))-instance-method","html_id":"[](range:Range(Int,Int))-instance-method","name":"[]","doc":"Returns all elements that are within the given range.\n\nNegative indices count backward from the end of the vector (-1 is the last\nelement). Additionally, an empty vector is returned when the starting index\nfor an element range is at the end of the vector.\n\nRaises `IndexError` if the starting index is out of range.\n\n```\nv = Vector{1.0, 2.0, 3.0, 4.0, 5.0}\nv[1..3] # => Vector{2.0, 3.0, 4.0}\nv[6..10] # raise IndexError\n```","summary":"

Returns all elements that are within the given range.

","abstract":false,"args":[{"name":"range","doc":null,"default_value":"","external_name":"range","restriction":"Range(Int, Int)"}],"args_string":"(range : Range(Int, Int))","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L173","def":{"name":"[]","args":[{"name":"range","doc":null,"default_value":"","external_name":"range","restriction":"Range(Int, Int)"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"self[*Indexable.range_to_index_and_count(range, size)]"}},{"id":"[]=(index:Int,count:Int,values:Vector)-instance-method","html_id":"[]=(index:Int,count:Int,values:Vector)-instance-method","name":"[]=","doc":"Replaces a subrange with the elements of the given vector.\n\n```\nvec = Vector{1.0, 2.0, 3.0, 4.0, 5.0}\nvec[1, 3] = Vector{6.0, 7.0, 8.0}\nvec # = Vector{1.0, 6.0, 7.0, 8.0, 5.0}\n\nvec = Vector{1.0, 2.0, 3.0, 4.0, 5.0}\nvec[1, 3] = Vector{6.0, 7.0}\nvec # = Vector{1.0, 6.0, 7.0, 5.0}\n```","summary":"

Replaces a subrange with the elements of the given vector.

","abstract":false,"args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"},{"name":"count","doc":null,"default_value":"","external_name":"count","restriction":"Int"},{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":"Vector"}],"args_string":"(index : Int, count : Int, values : Vector)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L297","def":{"name":"[]=","args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"},{"name":"count","doc":null,"default_value":"","external_name":"count","restriction":"Int"},{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":"Vector"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if count < 0\n raise(ArgumentError.new(\"Negative count: #{count}\"))\nend\nindex = check_index_out_of_bounds(index)\ncount = ((index + count) <= size) ? count : size - index\ndiff = values.size - count\nif diff == 0\n (@buffer + index).copy_from(values.to_unsafe, values.size)\nelse\n if diff < 0\n diff = -diff\n (@buffer + index).copy_from(values.to_unsafe, values.size)\n ((@buffer + index) + values.size).move_from((@buffer + index) + count, (size - index) - count)\n ((@buffer + @size) - diff).clear(diff)\n @size = @size - diff\n else\n resize_to_capacity(Math.pw2ceil(@size + diff))\n ((@buffer + index) + values.size).move_from((@buffer + index) + count, (size - index) - count)\n (@buffer + index).copy_from(values.to_unsafe, values.size)\n @size = @size + diff\n end\nend\nvalues\n"}},{"id":"[]=(index:Int,count:Int,value)-instance-method","html_id":"[]=(index:Int,count:Int,value)-instance-method","name":"[]=","doc":"Replaces a subrange with a single value. All elements in the range\n`index...index+count` are removed and replaced by a single element\n*value*.\n\nIf *count* is zero, *value* is inserted at *index*.\n\nNegative values of *index* count from the end of the vector.\n\n```\nvec = Vector{1.0, 2.0, 3.0, 4.0, 5.0}\nvec[1, 3] = 6.0\nvec # => Vector{1.0, 6.0, 5.0}\n\nvec = Vector{1.0, 2.0, 3.0, 4.0, 5.0}\nvec[1, 0] = 6.0\nvec # => Vector{1.0, 6.0, 2.0, 3.0, 4.0, 5.0}\n```","summary":"

Replaces a subrange with a single value.

","abstract":false,"args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"},{"name":"count","doc":null,"default_value":"","external_name":"count","restriction":"Int"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(index : Int, count : Int, value)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L248","def":{"name":"[]=","args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"},{"name":"count","doc":null,"default_value":"","external_name":"count","restriction":"Int"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if count < 0\n raise(ArgumentError.new(\"Negative count: #{count}\"))\nend\nvalue = value.to_f64\nindex = check_index_out_of_bounds(index)\ncount = ((index + count) <= size) ? count : size - index\ncase count\nwhen 0\n insert(index, value)\nwhen 1\n @buffer[index] = value\nelse\n diff = count - 1\n ((@buffer + index) + 1).move_from((@buffer + index) + count, (size - index) - count)\n ((@buffer + @size) - diff).clear(diff)\n @buffer[index] = value\n @size = @size - diff\nend\nvalue\n"}},{"id":"[]=(index:Int,value)-instance-method","html_id":"[]=(index:Int,value)-instance-method","name":"[]=","doc":"Sets the given value at the given index.\n\nNegative indices can be used to start counting from the end of the array.\nRaises `IndexError` if trying to set an element outside the array's range.\n\n```\nvec = Vector{1.0, 2.0, 3.0}\nvec[0] = 5.0\np vec # => Vec{5.0, 2.0, 3.0}\n\nvec[3] = 5.0 # raises IndexError\n```","summary":"

Sets the given value at the given index.

","abstract":false,"args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(index : Int, value)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L226","def":{"name":"[]=","args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"index = check_index_out_of_bounds(index)\n@buffer[index] = value.to_f64\n"}},{"id":"[]=(range:Range(Int,Int),value)-instance-method","html_id":"[]=(range:Range(Int,Int),value)-instance-method","name":"[]=","doc":"Replaces a subrange with a single value.\n\n```\nvec = Vector{1.0, 2.0, 3.0, 4.0, 5.0}\nvec[1..3] = 6.0\nvec # = Vector{1.0, 6.0, 5.0}\n\nvec = Vector{1.0, 2.0, 3.0, 4.0, 5.0}\nvec[1...1] = 6\nvec # = Vector{1.0, 6.0, 2.0, 3.0, 4.0, 5.0}\n```","summary":"

Replaces a subrange with a single value.

","abstract":false,"args":[{"name":"range","doc":null,"default_value":"","external_name":"range","restriction":"Range(Int, Int)"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(range : Range(Int, Int), value)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L282","def":{"name":"[]=","args":[{"name":"range","doc":null,"default_value":"","external_name":"range","restriction":"Range(Int, Int)"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"self[*Indexable.range_to_index_and_count(range, size)] = value.to_f64"}},{"id":"add(value)-instance-method","html_id":"add(value)-instance-method","name":"add","doc":"When the input is a number, this returns the result of adding\nit to all vector elements. When it's a vector, the vectors\nwill be added together.","summary":"

When the input is a number, this returns the result of adding it to all vector elements.

","abstract":false,"args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(value)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L488","def":{"name":"add","args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"run_binary_op(value) do |a, b|\n a + b\nend"}},{"id":"angle_from(vector)-instance-method","html_id":"angle_from(vector)-instance-method","name":"angle_from","doc":"Returns the angle between this vector and another in radians.\nIf the vectors are mirrored across their axes this will return `nil`.","summary":"

Returns the angle between this vector and another in radians.

","abstract":false,"args":[{"name":"vector","doc":null,"default_value":"","external_name":"vector","restriction":""}],"args_string":"(vector)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L440","def":{"name":"angle_from","args":[{"name":"vector","doc":null,"default_value":"","external_name":"vector","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"v = vector.is_a?(Vector) ? vector : Vector.create(vector)\nif size == v.size\nelse\n raise(\"Cannot compute the angle between vectors with different dimensionality\")\nend\ndot = 0_f64\nmod1 = 0_f64\nmod2 = 0_f64\n(zip(vector)).each do |x, v|\n dot = dot + (x * v)\n mod1 = mod1 + (x * x)\n mod2 = mod2 + (v * v)\nend\nmod1 = Math.sqrt(mod1)\nmod2 = Math.sqrt(mod2)\nif (mod2 * mod2) == 0\n return 0.0\nend\ntheta = (dot / (mod1 * mod2)).clamp(-1, 1)\nMath.acos(theta)\n"}},{"id":"antiparallel_to?(vector)-instance-method","html_id":"antiparallel_to?(vector)-instance-method","name":"antiparallel_to?","doc":"Returns whether the vectors are antiparallel to each other.","summary":"

Returns whether the vectors are antiparallel to each other.

","abstract":false,"args":[{"name":"vector","doc":null,"default_value":"","external_name":"vector","restriction":""}],"args_string":"(vector)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L475","def":{"name":"antiparallel_to?","args":[{"name":"vector","doc":null,"default_value":"","external_name":"vector","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"angle = angle_from(vector)\n(angle - Math::PI).abs <= Apatite.precision\n"}},{"id":"augment(elements)-instance-method","html_id":"augment(elements)-instance-method","name":"augment","doc":"Returns a new vector with the provided `elements` concatenated\non the end.","summary":"

Returns a new vector with the provided elements concatenated on the end.

","abstract":false,"args":[{"name":"elements","doc":null,"default_value":"","external_name":"elements","restriction":""}],"args_string":"(elements)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L556","def":{"name":"augment","args":[{"name":"elements","doc":null,"default_value":"","external_name":"elements","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"elements = elements.is_a?(Vector) ? elements : Vector.create(elements)\nconcat(elements)\n"}},{"id":"chomp(n)-instance-method","html_id":"chomp(n)-instance-method","name":"chomp","doc":"Returns a new vector with the first `n` elements removed from\nthe beginning.","summary":"

Returns a new vector with the first n elements removed from the beginning.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L541","def":{"name":"chomp","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"elements = [] of Float64\neach_with_index do |e, i|\n if i >= n\n elements << e\n end\nend\nVector.create(elements)\n"}},{"id":"clear-instance-method","html_id":"clear-instance-method","name":"clear","doc":"Removes all elements from self.\n\n```\nvec = Vector{1.0, 2.0, 3.0}\nvec.clear # => Vector{}\n```","summary":"

Removes all elements from self.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L782","def":{"name":"clear","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@buffer.clear(@size)\n@size = 0\nself\n"}},{"id":"clone-instance-method","html_id":"clone-instance-method","name":"clone","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L374","def":{"name":"clone","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.create(@elements.clone)"}},{"id":"concat(other:Vector)-instance-method","html_id":"concat(other:Vector)-instance-method","name":"concat","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Vector"}],"args_string":"(other : Vector)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L731","def":{"name":"concat","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Vector"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"other_size = other.size\nnew_size = size + other_size\nif new_size > @capacity\n resize_to_capacity(Math.pw2ceil(new_size))\nend\n(@buffer + @size).copy_from(other.to_unsafe, other_size)\n@size = new_size\nself\n"}},{"id":"covector-instance-method","html_id":"covector-instance-method","name":"covector","doc":"Creates a single-row matrix from this vector.","summary":"

Creates a single-row matrix from this vector.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L601","def":{"name":"covector","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.row_vector(self)"}},{"id":"cross(*vs)-instance-method","html_id":"cross(*vs)-instance-method","name":"cross","doc":"Returns the cross product of this vector with the others.\n\n```\nv1 = Vector{1.0, 0.0, 0.0}\nv2 = Vector{0.0, 1.0, 0.0}\nv1.cross(v2) => Vector{0.0, 0.0, 1.0}\n```","summary":"

Returns the cross product of this vector with the others.

","abstract":false,"args":[{"name":"vs","doc":null,"default_value":"","external_name":"vs","restriction":""}],"args_string":"(*vs)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L518","def":{"name":"cross","args":[{"name":"vs","doc":null,"default_value":"","external_name":"vs","restriction":""}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if size >= 2\nelse\n raise(\"cross product is not defined on vectors of dimension #{size}\")\nend\nif vs.size == (size - 2)\nelse\n raise(ArgumentError.new(\"wrong number of arguments (#{vs.size} for #{size - 2})\"))\nend\nvs.each do |v|\n if v.size == size\n else\n raise(\"Dimension mismatch. Vectors not all the same size.\")\n end\nend\ncase size\nwhen 2\n Vector[-@buffer[1], @buffer[0]]\nwhen 3\n v = vs[0]\n Vector[(v[2] * @buffer[1]) - (v[1] * @buffer[2]), (v[0] * @buffer[2]) - (v[2] * @buffer[0]), (v[1] * @buffer[0]) - (v[0] * @buffer[1])]\nelse\nend\n"}},{"id":"distance_from(obj)-instance-method","html_id":"distance_from(obj)-instance-method","name":"distance_from","doc":"Gets this vector's distance from the argument, when considered\na point in space.","summary":"

Gets this vector's distance from the argument, when considered a point in space.

","abstract":false,"args":[{"name":"obj","doc":null,"default_value":"","external_name":"obj","restriction":""}],"args_string":"(obj)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L629","def":{"name":"distance_from","args":[{"name":"obj","doc":null,"default_value":"","external_name":"obj","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if object.is_a?(Plane) || object.is_a?(Line)\n return object.distance_from(self)\nend\nv = elements.is_a?(Vector) ? elements.elements : elements\nif v.size == @elements.size\nelse\n return nil\nend\nsum = 0\npart = 0\neach_with_index do |x, i|\n part = x - v[i - 1]\n sum = sum + (part * part)\nend\nMath.sqrt(sum)\n"}},{"id":"dot(other)-instance-method","html_id":"dot(other)-instance-method","name":"dot","doc":"Get the scalar (dot) product of this vector with `vector`.\n\n[https://en.wikipedia.org/wiki/Scalar_product](https://en.wikipedia.org/wiki/Scalar_product)","summary":"

Get the scalar (dot) product of this vector with vector.

","abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"args_string":"(other)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L574","def":{"name":"dot","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"other = other.is_a?(Vector) ? other : Vector.create(other)\nif size == other.size\nelse\n raise(\"Cannot compute the dot product of vectors with different dimensionality\")\nend\nproduct = 0\n(0...size).each do |i|\n product = product + (self[i] * other[i])\nend\nproduct\n"}},{"id":"e(i)-instance-method","html_id":"e(i)-instance-method","name":"e","doc":"Returns the `ith` element of the vector. Returns `nil` if `i`\nis out of bounds. Indexing starts from 1.","summary":"

Returns the ith element of the vector.

","abstract":false,"args":[{"name":"i","doc":null,"default_value":"","external_name":"i","restriction":""}],"args_string":"(i)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L426","def":{"name":"e","args":[{"name":"i","doc":null,"default_value":"","external_name":"i","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"(i < 1 || i > @size) ? nil : self[i - 1]"}},{"id":"independent?(*vs)-instance-method","html_id":"independent?(*vs)-instance-method","name":"independent?","doc":"Returns true if all vectors are linearly independent.","summary":"

Returns true if all vectors are linearly independent.

","abstract":false,"args":[{"name":"vs","doc":null,"default_value":"","external_name":"vs","restriction":""}],"args_string":"(*vs)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L384","def":{"name":"independent?","args":[{"name":"vs","doc":null,"default_value":"","external_name":"vs","restriction":""}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"vs.each do |v|\n if v.size == vs.first.size\n else\n raise(\"Dimension mismatch. Vectors not all the same size.\")\n end\nend\nif vs.size > sv.first.size\n return false\nend\nMatrix[*vs].rank.equal?(vs.count)\n"}},{"id":"lies_in(plane)-instance-method","html_id":"lies_in(plane)-instance-method","name":"lies_in","doc":"Returns true if the vector is a point on the given plane.","summary":"

Returns true if the vector is a point on the given plane.

","abstract":false,"args":[{"name":"plane","doc":null,"default_value":"","external_name":"plane","restriction":""}],"args_string":"(plane)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L654","def":{"name":"lies_in","args":[{"name":"plane","doc":null,"default_value":"","external_name":"plane","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"plane.contains(self)"}},{"id":"lies_on(line)-instance-method","html_id":"lies_on(line)-instance-method","name":"lies_on","doc":"Returns true if the vector is a point on the given line","summary":"

Returns true if the vector is a point on the given line

","abstract":false,"args":[{"name":"line","doc":null,"default_value":"","external_name":"line","restriction":""}],"args_string":"(line)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L649","def":{"name":"lies_on","args":[{"name":"line","doc":null,"default_value":"","external_name":"line","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"line.contains(self)"}},{"id":"log-instance-method","html_id":"log-instance-method","name":"log","doc":"Return a new `Vector` with the log of every item in `self`.","summary":"

Return a new Vector with the log of every item in self.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L562","def":{"name":"log","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"map do |x|\n Math.log(x)\nend"}},{"id":"magnitude-instance-method","html_id":"magnitude-instance-method","name":"magnitude","doc":"Returns the magnitude/euclidian norm of this vector.\n\n[https://en.wikipedia.org/wiki/Euclidean_distance](https://en.wikipedia.org/wiki/Euclidean_distance)","summary":"

Returns the magnitude/euclidian norm of this vector.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L419","def":{"name":"magnitude","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"sum = reduce(0.0) do |acc, e|\n acc = acc + (e * e)\nend\nMath.sqrt(sum)\n"}},{"id":"map(&block)-instance-method","html_id":"map(&block)-instance-method","name":"map","doc":"Invokes the given block for each element of `self`.","summary":"

Invokes the given block for each element of self.

","abstract":false,"args":[],"args_string":"(&block)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L379","def":{"name":"map","args":[],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.new(size) do |i|\n yield @buffer[i]\nend"}},{"id":"map!(&block)-instance-method","html_id":"map!(&block)-instance-method","name":"map!","doc":"Invokes the given block for each element of `self`, replacing the element\nwith the value returned by the block. Returns `self`.\n\n```\nvec = Vector{1.0, 2.0, 3.0}\nvec.map! { |x| x * x }\na # => Vector{1.0, 4.0, 9.0}\n```","summary":"

Invokes the given block for each element of self, replacing the element with the value returned by the block.

","abstract":false,"args":[],"args_string":"(&block)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L400","def":{"name":"map!","args":[],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"@buffer.map!(size) do |e|\n yield e\nend\nself\n"}},{"id":"map_with_index(&block)-instance-method","html_id":"map_with_index(&block)-instance-method","name":"map_with_index","doc":"Optimized version of `Enumerable#map_with_index`.","summary":"

Optimized version of Enumerable#map_with_index.

","abstract":false,"args":[],"args_string":"(&block)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L406","def":{"name":"map_with_index","args":[],"double_splat":null,"splat_index":null,"yields":2,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.new(size) do |i|\n yield @buffer[i], i\nend"}},{"id":"map_with_index!(&block)-instance-method","html_id":"map_with_index!(&block)-instance-method","name":"map_with_index!","doc":"Like `map_with_index`, but mutates `self` instead of allocating a new object.","summary":"

Like #map_with_index, but mutates self instead of allocating a new object.

","abstract":false,"args":[],"args_string":"(&block)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L411","def":{"name":"map_with_index!","args":[],"double_splat":null,"splat_index":null,"yields":2,"block_arg":null,"return_type":"","visibility":"Public","body":"to_unsafe.map_with_index!(size) do |e, i|\n yield e, i\nend\nself\n"}},{"id":"max-instance-method","html_id":"max-instance-method","name":"max","doc":"Returns the (absolute) largest element in this vector.","summary":"

Returns the (absolute) largest element in this vector.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L589","def":{"name":"max","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"reduce do |acc, i|\n i.abs > acc.abs ? i : acc\nend"}},{"id":"max_index-instance-method","html_id":"max_index-instance-method","name":"max_index","doc":"Gets the index of the largest element in this vector.","summary":"

Gets the index of the largest element in this vector.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L594","def":{"name":"max_index","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"idx = 0\neach_with_index do |e, i|\n idx = e.abs > self[idx].abs ? i : idx\nend\nidx\n"}},{"id":"multiply(value)-instance-method","html_id":"multiply(value)-instance-method","name":"multiply","doc":"When the input is a number, this returns the result of multiplying\nit to all vector elements. When it's a vector, the vectors\nwill be element-wise multiplied.","summary":"

When the input is a number, this returns the result of multiplying it to all vector elements.

","abstract":false,"args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(value)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L502","def":{"name":"multiply","args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"run_binary_op(value) do |a, b|\n a * b\nend"}},{"id":"parallel_to?(vector)-instance-method","html_id":"parallel_to?(vector)-instance-method","name":"parallel_to?","doc":"Returns whether the vectors are parallel to each other.","summary":"

Returns whether the vectors are parallel to each other.

","abstract":false,"args":[{"name":"vector","doc":null,"default_value":"","external_name":"vector","restriction":""}],"args_string":"(vector)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L469","def":{"name":"parallel_to?","args":[{"name":"vector","doc":null,"default_value":"","external_name":"vector","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"angle = angle_from(vector)\nangle <= Apatite.precision\n"}},{"id":"perpendicular_to?(vector)-instance-method","html_id":"perpendicular_to?(vector)-instance-method","name":"perpendicular_to?","doc":"Returns whether the vectors are perpendicular to each other.","summary":"

Returns whether the vectors are perpendicular to each other.

","abstract":false,"args":[{"name":"vector","doc":null,"default_value":"","external_name":"vector","restriction":""}],"args_string":"(vector)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L481","def":{"name":"perpendicular_to?","args":[{"name":"vector","doc":null,"default_value":"","external_name":"vector","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"(dot(vector)).abs <= Apatite.precision"}},{"id":"pretty_print(pp):Nil-instance-method","html_id":"pretty_print(pp):Nil-instance-method","name":"pretty_print","doc":null,"summary":null,"abstract":false,"args":[{"name":"pp","doc":null,"default_value":"","external_name":"pp","restriction":""}],"args_string":"(pp) : Nil","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L754","def":{"name":"pretty_print","args":[{"name":"pp","doc":null,"default_value":"","external_name":"pp","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Nil","visibility":"Public","body":"pp.list(\"Vector{\", self, \"}\")"}},{"id":"product-instance-method","html_id":"product-instance-method","name":"product","doc":"Get the product of all elements in this vector.","summary":"

Get the product of all elements in this vector.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L567","def":{"name":"product","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"reduce do |acc, v|\n acc = acc * v\nend"}},{"id":"push(*values:Float64)-instance-method","html_id":"push(*values:Float64)-instance-method","name":"push","doc":null,"summary":null,"abstract":false,"args":[{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":"Float64"}],"args_string":"(*values : Float64)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L665","def":{"name":"push","args":[{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":"Float64"}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"new_size = @size + values.size\nif new_size > @capacity\n resize_to_capacity(Math.pw2ceil(new_size))\nend\nvalues.each_with_index do |value, i|\n @buffer[@size + i] = value\nend\n@size = new_size\nself\n"}},{"id":"push(value:Float64)-instance-method","html_id":"push(value:Float64)-instance-method","name":"push","doc":null,"summary":null,"abstract":false,"args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":"Float64"}],"args_string":"(value : Float64)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L658","def":{"name":"push","args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":"Float64"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"check_needs_resize\n@buffer[@size] = value\n@size = @size + 1\nself\n"}},{"id":"reflection_in(object)-instance-method","html_id":"reflection_in(object)-instance-method","name":"reflection_in","doc":"Returns the result of reflecting the point in the given `object`\n(point, line, or plane).","summary":"

Returns the result of reflecting the point in the given object (point, line, or plane).

","abstract":false,"args":[{"name":"object","doc":null,"default_value":"","external_name":"object","restriction":""}],"args_string":"(object)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L684","def":{"name":"reflection_in","args":[{"name":"object","doc":null,"default_value":"","external_name":"object","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if object.is_a?(Plane) || object.is_a?(Line)\n p = @elements.dup\n c = (object.point_closest_to(p)).elements\n return Vector.create([C[0] + (C[0] - P[0]), C[1] + (C[1] - P[1]), C[2] + (C[2] - (P[2] || 0))])\nend\nq = object.is_a?(Vector) ? object.elements : object\nif @elements.size == q.size\nelse\n return nil\nend\nmap_with_index do |x, i|\n q[i - 1] + (q[i - 1] - x)\nend\n"}},{"id":"rotate(t,object)-instance-method","html_id":"rotate(t,object)-instance-method","name":"rotate","doc":"Rotates the vector about the given `object`. The object should\nbe a point if the vector is 2D, and a line if it is 3D. Be\ncareful with line directions!","summary":"

Rotates the vector about the given object.

","abstract":false,"args":[{"name":"t","doc":null,"default_value":"","external_name":"t","restriction":""},{"name":"object","doc":null,"default_value":"","external_name":"object","restriction":""}],"args_string":"(t, object)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L678","def":{"name":"rotate","args":[{"name":"t","doc":null,"default_value":"","external_name":"t","restriction":""},{"name":"object","doc":null,"default_value":"","external_name":"object","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":""}},{"id":"round-instance-method","html_id":"round-instance-method","name":"round","doc":"Gets the result of rounding the elements of the vector.","summary":"

Gets the result of rounding the elements of the vector.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L612","def":{"name":"round","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"map do |x|\n x.round\nend"}},{"id":"set_elements(elements)-instance-method","html_id":"set_elements(elements)-instance-method","name":"set_elements","doc":null,"summary":null,"abstract":false,"args":[{"name":"elements","doc":null,"default_value":"","external_name":"elements","restriction":""}],"args_string":"(elements)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L726","def":{"name":"set_elements","args":[{"name":"elements","doc":null,"default_value":"","external_name":"elements","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@elements = elements.is_a?(Vector) ? elements.elements : elements\nself\n"}},{"id":"sigmoid-instance-method","html_id":"sigmoid-instance-method","name":"sigmoid","doc":"Sums the numbers in the vector and returns a sigmoid value\nacross the whole vector.","summary":"

Sums the numbers in the vector and returns a sigmoid value across the whole vector.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L707","def":{"name":"sigmoid","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"LinearAlgebra.sigmoid(sum)"}},{"id":"size:Int32-instance-method","html_id":"size:Int32-instance-method","name":"size","doc":"Returns the number of elements in the vector","summary":"

Returns the number of elements in the vector

","abstract":false,"args":[],"args_string":" : Int32","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L24","def":{"name":"size","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Int32","visibility":"Public","body":"@size"}},{"id":"snap_to(value)-instance-method","html_id":"snap_to(value)-instance-method","name":"snap_to","doc":"Returns a copy of the vector with elements set to `value` if\nthey differ from it by less than `Apetite.precision`","summary":"

Returns a copy of the vector with elements set to value if they differ from it by less than Apetite.precision

","abstract":false,"args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(value)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L623","def":{"name":"snap_to","args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"map do |y|\n (y - x).abs <= Apetite.precision ? value : y\nend"}},{"id":"subtract(value)-instance-method","html_id":"subtract(value)-instance-method","name":"subtract","doc":"When the input is a number, this returns the result of subtracting\nit to all vector elements. When it's a vector, the vectors\nwill be subtracted.","summary":"

When the input is a number, this returns the result of subtracting it to all vector elements.

","abstract":false,"args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(value)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L495","def":{"name":"subtract","args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"run_binary_op(value) do |a, b|\n a - b\nend"}},{"id":"sum-instance-method","html_id":"sum-instance-method","name":"sum","doc":"Returns the sum of all elements in the vector.","summary":"

Returns the sum of all elements in the vector.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L507","def":{"name":"sum","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"reduce(0) do |acc, i|\n acc + i\nend"}},{"id":"to_3d-instance-method","html_id":"to_3d-instance-method","name":"to_3d","doc":"Utility to make sure vectors are 3D. If they are 2D, a zero\nz-component is added.","summary":"

Utility to make sure vectors are 3D.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L713","def":{"name":"to_3d","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"v = dup\ncase v.elements.size\nwhen 3\n break\nwhen 2\n v.elements.push(0)\nelse\n return nil\nend\nreturn v\n"}},{"id":"to_a-instance-method","html_id":"to_a-instance-method","name":"to_a","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L744","def":{"name":"to_a","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Array(Float64).new(size) do |i|\n self[i]\nend"}},{"id":"to_diagonal_matrix-instance-method","html_id":"to_diagonal_matrix-instance-method","name":"to_diagonal_matrix","doc":"Returns a diagonal `Matrix` with the vectors elements as its\ndiagonal elements.","summary":"

Returns a diagonal Matrix with the vectors elements as its diagonal elements.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L607","def":{"name":"to_diagonal_matrix","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix::Diagonal.new(elements)"}},{"id":"to_s(io)-instance-method","html_id":"to_s(io)-instance-method","name":"to_s","doc":null,"summary":null,"abstract":false,"args":[{"name":"io","doc":null,"default_value":"","external_name":"io","restriction":""}],"args_string":"(io)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L748","def":{"name":"to_s","args":[{"name":"io","doc":null,"default_value":"","external_name":"io","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"io << \"{\"\njoin(\", \", io, &.inspect(io))\nio << \"}\"\n"}},{"id":"to_unit_vector-instance-method","html_id":"to_unit_vector-instance-method","name":"to_unit_vector","doc":"Returns a new vector created by normalizing this one\nto have a magnitude of `1`. If the vector is a zero\nvector, it will not be modified.","summary":"

Returns a new vector created by normalizing this one to have a magnitude of 1.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L433","def":{"name":"to_unit_vector","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"r = magnitude\nr == 0 ? dup : map do |x|\n x.to_f64 / r\nend\n"}},{"id":"to_unsafe:Pointer(Float64)-instance-method","html_id":"to_unsafe:Pointer(Float64)-instance-method","name":"to_unsafe","doc":"Returns a pointer to the internal buffer where `self`'s elements are stored.\n\nThis method is **unsafe** because it returns a pointer, and the pointed might eventually\nnot be that of `self` if the array grows and its internal buffer is reallocated.\n\n```\nvec = Vector{1.0, 2.0, 3.0}\nvec.to_unsafe[0] # => 1.0\n```","summary":"

Returns a pointer to the internal buffer where self's elements are stored.

","abstract":false,"args":[],"args_string":" : Pointer(Float64)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L772","def":{"name":"to_unsafe","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Pointer(Float64)","visibility":"Public","body":"@buffer"}},{"id":"top(n)-instance-method","html_id":"top(n)-instance-method","name":"top","doc":"Returns a vector containing only the first `n` elements.","summary":"

Returns a vector containing only the first n elements.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L548","def":{"name":"top","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"elements = [] of Float64\neach_with_index do |e, i|\n if i < n\n elements << e\n end\nend\nVector.create(elements)\n"}},{"id":"transpose-instance-method","html_id":"transpose-instance-method","name":"transpose","doc":"Transpose this vector into a 1xn `Matrix`","summary":"

Transpose this vector into a 1xn Matrix

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L617","def":{"name":"transpose","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.col_vector(self)"}},{"id":"unsafe_fetch(index:Int)-instance-method","html_id":"unsafe_fetch(index:Int)-instance-method","name":"unsafe_fetch","doc":null,"summary":null,"abstract":false,"args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"}],"args_string":"(index : Int)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L759","def":{"name":"unsafe_fetch","args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@buffer[index]"}},{"id":"zero?-instance-method","html_id":"zero?-instance-method","name":"zero?","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L788","def":{"name":"zero?","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"all?(&.zero?)"}}],"macros":[],"types":[]}]}]},{"html_id":"github.com/watzon/apatite/Array","path":"Array.html","kind":"class","full_name":"Array(T)","name":"Array","abstract":false,"superclass":{"html_id":"github.com/watzon/apatite/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"github.com/watzon/apatite/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"github.com/watzon/apatite/Indexable","kind":"module","full_name":"Indexable","name":"Indexable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Iterable","kind":"module","full_name":"Iterable","name":"Iterable"},{"html_id":"github.com/watzon/apatite/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"github.com/watzon/apatite/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"apatite/core_ext/array.cr","line_number":1,"url":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/core_ext/array.cr"}],"repository_name":"github.com/watzon/apatite","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[{"html_id":"github.com/watzon/apatite/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"github.com/watzon/apatite/Indexable","kind":"module","full_name":"Indexable","name":"Indexable"}],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":null,"doc":"An `Array` is an ordered, integer-indexed collection of objects of type T.\n\nArray indexing starts at 0. A negative index is assumed to be\nrelative to the end of the array: -1 indicates the last element,\n-2 is the next to last element, and so on.\n\nAn `Array` can be created using the usual `new` method (several are provided), or with an array literal:\n\n```\nArray(Int32).new # => []\n[1, 2, 3] # Array(Int32)\n[1, \"hello\", 'x'] # Array(Int32 | String | Char)\n```\n\nAn `Array` can have mixed types, meaning T will be a union of types, but these are determined\nwhen the array is created, either by specifying T or by using an array literal. In the latter\ncase, T will be set to the union of the array literal elements' types.\n\nWhen creating an empty array you must always specify T:\n\n```\n[] of Int32 # same as Array(Int32)\n[] # syntax error\n```\n\nAn `Array` is implemented using an internal buffer of some capacity\nand is reallocated when elements are pushed to it when more capacity\nis needed. This is normally known as a [dynamic array](http://en.wikipedia.org/wiki/Dynamic_array).\n\nYou can use a special array literal syntax with other types too, as long as they define an argless\n`new` method and a `<<` method. `Set` is one such type:\n\n```\nset = Set{1, 2, 3} # => Set{1, 2, 3}\nset.class # => Set(Int32)\n```\n\nThe above is the same as this:\n\n```\nset = Set(typeof(1, 2, 3)).new\nset << 1\nset << 2\nset << 3\n```","summary":"

An Array is an ordered, integer-indexed collection of objects of type T.

","class_methods":[],"constructors":[],"instance_methods":[{"id":"all?-instance-method","html_id":"all?-instance-method","name":"all?","doc":"Tests whether all elements evaluate to true","summary":"

Tests whether all elements evaluate to true

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/core_ext/array.cr#L3","def":{"name":"all?","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"each do |i|\n if (!(!i)) == false\n return false\n end\nend\ntrue\n"}},{"id":"any?-instance-method","html_id":"any?-instance-method","name":"any?","doc":"Tests whether any of the elements evaluate to true","summary":"

Tests whether any of the elements evaluate to true

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/core_ext/array.cr#L11","def":{"name":"any?","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"each do |i|\n if (!(!i)) == true\n return true\n end\nend\nfalse\n"}},{"id":"shape-instance-method","html_id":"shape-instance-method","name":"shape","doc":"Get the array's dimensions","summary":"

Get the array's dimensions

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/core_ext/array.cr#L19","def":{"name":"shape","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"max = max_by do |i|\n i.is_a?(Array) ? i.size : i\nend\nmax.is_a?(Array) ? [size, max.size] : [max]\n"}},{"id":"to_vec-instance-method","html_id":"to_vec-instance-method","name":"to_vec","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/core_ext/array.cr#L24","def":{"name":"to_vec","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Apatite::Vector.create(self)"}}],"macros":[],"types":[]}]}} \ No newline at end of file +{"repository_name":"github.com/watzon/apatite","body":"# Apatite\n\nApatite is meant to be a collecion of mathmatical and scientific computing algorithms for the Crystal programming language. I don't expect it to ever reach the level of completeness as numpy, but hopefully it can save some people the trouble of implementing these methods on their own.\n\n## Installation\n\n1. Add the dependency to your `shard.yml`:\n\n ```yaml\n dependencies:\n apatite:\n github: watzon/apatite\n ```\n\n2. Run `shards install`\n\n## Usage\n\n```crystal\nrequire \"apatite\"\n```\n\nTODO: Write usage instructions here, but first write the library...\n\n## Roadmap\n\n- [ ] Apetite\n\t- [ ] Vector Math\n\t\t- [ ] Matrix\n\t\t- [ ] NDArray\n\t\t- [x] Vector\n\t\t- [ ] Line\n\t\t- [ ] Plane\n\t\t- [ ] Polygon\n\t\t- [ ] LinkedList\n\t\n\n\n## Contributing\n\n1. Fork it ()\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n## Contributors\n\n- [Chris Watson](https://github.com/watzon) - creator and maintainer","program":{"html_id":"github.com/watzon/apatite/toplevel","path":"toplevel.html","kind":"module","full_name":"Top Level Namespace","name":"Top Level Namespace","abstract":false,"superclass":null,"ancestors":[],"locations":[],"repository_name":"github.com/watzon/apatite","program":true,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":null,"doc":null,"summary":null,"class_methods":[],"constructors":[],"instance_methods":[],"macros":[],"types":[{"html_id":"github.com/watzon/apatite/Apatite","path":"Apatite.html","kind":"module","full_name":"Apatite","name":"Apatite","abstract":false,"superclass":null,"ancestors":[{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra","kind":"module","full_name":"Apatite::LinearAlgebra","name":"LinearAlgebra"}],"locations":[{"filename":"apatite/linear_algebra/ndarray.cr","line_number":1,"url":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/ndarray.cr"},{"filename":"apatite/linear_algebra.cr","line_number":5,"url":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra.cr"},{"filename":"apatite.cr","line_number":10,"url":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite.cr"},{"filename":"apatite/version.cr","line_number":1,"url":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/version.cr"}],"repository_name":"github.com/watzon/apatite","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[{"id":"I","name":"I","value":"Vector::I","doc":"Cartesian unit vector I\n\n`Vector{1.0, 0.0, 0.0}`","summary":"

Cartesian unit vector I

"},{"id":"J","name":"J","value":"Vector::J","doc":"Cartesian unit vector J\n\n`Vector{0.0, 1.0, 0.0}`","summary":"

Cartesian unit vector J

"},{"id":"K","name":"K","value":"Vector::K","doc":"Cartesian unit vector K\n\n`Vector{0.0, 0.0, 1.0}`","summary":"

Cartesian unit vector K

"},{"id":"VERSION","name":"VERSION","value":"\"0.1.0\"","doc":null,"summary":null}],"included_modules":[{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra","kind":"module","full_name":"Apatite::LinearAlgebra","name":"LinearAlgebra"}],"extended_modules":[{"html_id":"github.com/watzon/apatite/Apatite","kind":"module","full_name":"Apatite","name":"Apatite"}],"subclasses":[],"including_types":[],"namespace":null,"doc":"Apatite is a fundimental package for scientific computing in Crystal. If that\nsounds like a modified version of the first line from the NumPy homepage,\nthat's because it is. Apatite has (ok, will have) all of the goodness\nof NumPy sitting atop the blazing speed and beautiful syntax\nof Crystal.","summary":"

Apatite is a fundimental package for scientific computing in Crystal.

","class_methods":[],"constructors":[],"instance_methods":[{"id":"as_vector(input:Indexable)-instance-method","html_id":"as_vector(input:Indexable)-instance-method","name":"as_vector","doc":"Creates a new vector from the given `input`. Input can be any\n`Indexable` type.","summary":"

Creates a new vector from the given input.

","abstract":false,"args":[{"name":"input","doc":null,"default_value":"","external_name":"input","restriction":"Indexable"}],"args_string":"(input : Indexable)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite.cr#L61","def":{"name":"as_vector","args":[{"name":"input","doc":null,"default_value":"","external_name":"input","restriction":"Indexable"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.create(input)"}},{"id":"basis(size,index)-instance-method","html_id":"basis(size,index)-instance-method","name":"basis","doc":"Creates a standard basis-n vector of the given `size` and `index`.","summary":"

Creates a standard basis-n vector of the given size and index.

","abstract":false,"args":[{"name":"size","doc":null,"default_value":"","external_name":"size","restriction":""},{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":""}],"args_string":"(size, index)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite.cr#L66","def":{"name":"basis","args":[{"name":"size","doc":null,"default_value":"","external_name":"size","restriction":""},{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.basis(size, index)"}},{"id":"diagonal(values)-instance-method","html_id":"diagonal(values)-instance-method","name":"diagonal","doc":"Creates a matrix where the diagonal elements are composed of `values`.","summary":"

Creates a matrix where the diagonal elements are composed of values.

","abstract":false,"args":[{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":""}],"args_string":"(values)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite.cr#L89","def":{"name":"diagonal","args":[{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.diagonal(values)"}},{"id":"empty-instance-method","html_id":"empty-instance-method","name":"empty","doc":"Returns a new empty `Vector`","summary":"

Returns a new empty Vector

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite.cr#L34","def":{"name":"empty","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.new"}},{"id":"empty_matrix(row_count=0,column_count=0)-instance-method","html_id":"empty_matrix(row_count=0,column_count=0)-instance-method","name":"empty_matrix","doc":"Creates a new empty matrix with the given `row_count` and\n`column_count`. At lease one of `row_count` or\n`column_count` must be zero.","summary":"

Creates a new empty matrix with the given row_count and column_count.

","abstract":false,"args":[{"name":"row_count","doc":null,"default_value":"0","external_name":"row_count","restriction":""},{"name":"column_count","doc":null,"default_value":"0","external_name":"column_count","restriction":""}],"args_string":"(row_count = 0, column_count = 0)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite.cr#L84","def":{"name":"empty_matrix","args":[{"name":"row_count","doc":null,"default_value":"0","external_name":"row_count","restriction":""},{"name":"column_count","doc":null,"default_value":"0","external_name":"column_count","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.new(rows, column_count)"}},{"id":"eye(n)-instance-method","html_id":"eye(n)-instance-method","name":"eye","doc":"Creates a new diagonal matrix of size `n` with ones in the diagonal\nand zeros elsewhere.","summary":"

Creates a new diagonal matrix of size n with ones in the diagonal and zeros elsewhere.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite.cr#L95","def":{"name":"eye","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.eye(n)"}},{"id":"full(n,i)-instance-method","html_id":"full(n,i)-instance-method","name":"full","doc":"Returns a new vector of size `n` filled with `i`","summary":"

Returns a new vector of size n filled with i

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""},{"name":"i","doc":null,"default_value":"","external_name":"i","restriction":""}],"args_string":"(n, i)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite.cr#L49","def":{"name":"full","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""},{"name":"i","doc":null,"default_value":"","external_name":"i","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.new(n, i)"}},{"id":"identity(n)-instance-method","html_id":"identity(n)-instance-method","name":"identity","doc":"Creates a `n x n` identity matrix.","summary":"

Creates a n x n identity matrix.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite.cr#L100","def":{"name":"identity","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.identity(n)"}},{"id":"ones(n)-instance-method","html_id":"ones(n)-instance-method","name":"ones","doc":"Returns a new vector filled with `n` ones.","summary":"

Returns a new vector filled with n ones.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite.cr#L39","def":{"name":"ones","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.ones(n)"}},{"id":"random(n,range=nil)-instance-method","html_id":"random(n,range=nil)-instance-method","name":"random","doc":"Creates a new vector of size `n` filled with random numbers. A `range`\ncan optionally be passed in if you want to limit the random numbers\nto a given range.","summary":"

Creates a new vector of size n filled with random numbers.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""},{"name":"range","doc":null,"default_value":"nil","external_name":"range","restriction":""}],"args_string":"(n, range = nil)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite.cr#L73","def":{"name":"random","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""},{"name":"range","doc":null,"default_value":"nil","external_name":"range","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.random(n, range)"}},{"id":"row_vector(row)-instance-method","html_id":"row_vector(row)-instance-method","name":"row_vector","doc":"Creates a single-row matrix where the values of that row are as given in `row`.","summary":"

Creates a single-row matrix where the values of that row are as given in row.

","abstract":false,"args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":""}],"args_string":"(row)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite.cr#L105","def":{"name":"row_vector","args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.row_vector(row)"}},{"id":"scalar(n,value)-instance-method","html_id":"scalar(n,value)-instance-method","name":"scalar","doc":"Creates an `n` by `n` diagonal matrix where each diagonal element is value.","summary":"

Creates an n by n diagonal matrix where each diagonal element is value.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(n, value)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite.cr#L110","def":{"name":"scalar","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.scalar(n, value)"}},{"id":"vector(n,&block)-instance-method","html_id":"vector(n,&block)-instance-method","name":"vector","doc":"Creates a new vector of size `n`, and invokes the block once\nfor each index of `self`, assigning the block's value in that index.","summary":"

Creates a new vector of size n, and invokes the block once for each index of self, assigning the block's value in that index.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n, &block)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite.cr#L55","def":{"name":"vector","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.new(n) do |i|\n yield i\nend"}},{"id":"zeros(n)-instance-method","html_id":"zeros(n)-instance-method","name":"zeros","doc":"Returns a new vector filled with `n` zeros.","summary":"

Returns a new vector filled with n zeros.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite.cr#L44","def":{"name":"zeros","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.zeros(n)"}}],"macros":[],"types":[{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra","path":"Apatite/LinearAlgebra.html","kind":"module","full_name":"Apatite::LinearAlgebra","name":"LinearAlgebra","abstract":false,"superclass":null,"ancestors":[],"locations":[{"filename":"apatite/linear_algebra/ndarray.cr","line_number":1,"url":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/ndarray.cr"},{"filename":"apatite/linear_algebra/vector.cr","line_number":1,"url":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr"},{"filename":"apatite/linear_algebra/matrix.cr","line_number":3,"url":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr"},{"filename":"apatite/linear_algebra.cr","line_number":6,"url":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra.cr"}],"repository_name":"github.com/watzon/apatite","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[],"extended_modules":[{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra","kind":"module","full_name":"Apatite::LinearAlgebra","name":"LinearAlgebra"}],"subclasses":[],"including_types":[{"html_id":"github.com/watzon/apatite/Apatite","kind":"module","full_name":"Apatite","name":"Apatite"}],"namespace":{"html_id":"github.com/watzon/apatite/Apatite","kind":"module","full_name":"Apatite","name":"Apatite"},"doc":null,"summary":null,"class_methods":[],"constructors":[],"instance_methods":[{"id":"sigmoid(input:Number)-instance-method","html_id":"sigmoid(input:Number)-instance-method","name":"sigmoid","doc":"Calculates the sigmoid curve for a numeric input.\n\n`f(x) = 1/(1 + e^-x)`\n\nSee also: [Sigmoid function (WikiWand)](https://www.wikiwand.com/en/Sigmoid_function)","summary":"

Calculates the sigmoid curve for a numeric input.

","abstract":false,"args":[{"name":"input","doc":null,"default_value":"","external_name":"input","restriction":"Number"}],"args_string":"(input : Number)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra.cr#L14","def":{"name":"sigmoid","args":[{"name":"input","doc":null,"default_value":"","external_name":"input","restriction":"Number"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"num = input.to_f64\n1 / (1 + (Math.exp(-num)))\n"}},{"id":"sigmoid_d(input:Number)-instance-method","html_id":"sigmoid_d(input:Number)-instance-method","name":"sigmoid_d","doc":"Calculates the derivative sigmoid curve for a numeric input.\n\n`f'(x) = f(x)(1 - f(x)),`","summary":"

Calculates the derivative sigmoid curve for a numeric input.

","abstract":false,"args":[{"name":"input","doc":null,"default_value":"","external_name":"input","restriction":"Number"}],"args_string":"(input : Number)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra.cr#L22","def":{"name":"sigmoid_d","args":[{"name":"input","doc":null,"default_value":"","external_name":"input","restriction":"Number"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"num = input.to_f64\nnum * (1 - num)\n"}}],"macros":[],"types":[{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra/Matrix","path":"Apatite/LinearAlgebra/Matrix.html","kind":"class","full_name":"Apatite::LinearAlgebra::Matrix","name":"Matrix","abstract":false,"superclass":{"html_id":"github.com/watzon/apatite/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"github.com/watzon/apatite/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"github.com/watzon/apatite/Indexable","kind":"module","full_name":"Indexable","name":"Indexable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Iterable","kind":"module","full_name":"Iterable","name":"Iterable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"github.com/watzon/apatite/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"apatite/linear_algebra/matrix.cr","line_number":4,"url":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr"}],"repository_name":"github.com/watzon/apatite","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[{"html_id":"github.com/watzon/apatite/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Indexable","kind":"module","full_name":"Indexable","name":"Indexable"}],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra","kind":"module","full_name":"Apatite::LinearAlgebra","name":"LinearAlgebra"},"doc":null,"summary":null,"class_methods":[{"id":"[](*rows)-class-method","html_id":"[](*rows)-class-method","name":"[]","doc":"Creates a matrix where each argument is a row.","summary":"

Creates a matrix where each argument is a row.

","abstract":false,"args":[{"name":"rows","doc":null,"default_value":"","external_name":"rows","restriction":""}],"args_string":"(*rows)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L22","def":{"name":"[]","args":[{"name":"rows","doc":null,"default_value":"","external_name":"rows","restriction":""}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"rows(rows)"}},{"id":"build(row_count,column_count=row_count,&block)-class-method","html_id":"build(row_count,column_count=row_count,&block)-class-method","name":"build","doc":"Creates a matrix of size `row_count x column_count`. It fills the values by calling\nthe given block, passing the current row and column.","summary":"

Creates a matrix of size row_count x column_count.

","abstract":false,"args":[{"name":"row_count","doc":null,"default_value":"","external_name":"row_count","restriction":""},{"name":"column_count","doc":null,"default_value":"row_count","external_name":"column_count","restriction":""}],"args_string":"(row_count, column_count = row_count, &block)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L28","def":{"name":"build","args":[{"name":"row_count","doc":null,"default_value":"","external_name":"row_count","restriction":""},{"name":"column_count","doc":null,"default_value":"row_count","external_name":"column_count","restriction":""}],"double_splat":null,"splat_index":null,"yields":2,"block_arg":null,"return_type":"","visibility":"Public","body":"if row_count < 0 || column_count < 0\n raise(ArgumentError.new)\nend\nrows = Array.new(row_count) do |i|\n Vector.new(column_count) do |j|\n yield i, j\n end\nend\nMatrix.new(rows, column_count)\n"}},{"id":"col_vector(column)-class-method","html_id":"col_vector(column)-class-method","name":"col_vector","doc":"Creates a single-column matrix where the values of that column are as given in column.","summary":"

Creates a single-column matrix where the values of that column are as given in column.

","abstract":false,"args":[{"name":"column","doc":null,"default_value":"","external_name":"column","restriction":""}],"args_string":"(column)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L39","def":{"name":"col_vector","args":[{"name":"column","doc":null,"default_value":"","external_name":"column","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.new([column].transpose, 1)"}},{"id":"columns(columns)-class-method","html_id":"columns(columns)-class-method","name":"columns","doc":"Creates a matrix using `columns` as an array of column vectors.","summary":"

Creates a matrix using .columns as an array of column vectors.

","abstract":false,"args":[{"name":"columns","doc":null,"default_value":"","external_name":"columns","restriction":""}],"args_string":"(columns)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L44","def":{"name":"columns","args":[{"name":"columns","doc":null,"default_value":"","external_name":"columns","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"(rows(columns)).transpose"}},{"id":"diagonal(values)-class-method","html_id":"diagonal(values)-class-method","name":"diagonal","doc":"Creates a matrix where the diagonal elements are composed of `values`.","summary":"

Creates a matrix where the diagonal elements are composed of values.

","abstract":false,"args":[{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":""}],"args_string":"(values)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L70","def":{"name":"diagonal","args":[{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"size = values.size\nif size == 0\n return Matrix.empty\nend\nrows = Array.new(size) do |j|\n row = Array.new(size, 0)\n row[j] = values[j]\n row\nend\nnew(rows)\n"}},{"id":"diagonal(*values)-class-method","html_id":"diagonal(*values)-class-method","name":"diagonal","doc":"Creates a matrix where the diagonal elements are composed of `values`.","summary":"

Creates a matrix where the diagonal elements are composed of values.

","abstract":false,"args":[{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":""}],"args_string":"(*values)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L84","def":{"name":"diagonal","args":[{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":""}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.diagonal(values)"}},{"id":"empty(row_count=0,column_count=0)-class-method","html_id":"empty(row_count=0,column_count=0)-class-method","name":"empty","doc":"Creates a empty matrix of `row_count x column_count`. At least one of\n`row_count` or `column_count` must be 0.","summary":"

Creates a empty matrix of row_count x column_count.

","abstract":false,"args":[{"name":"row_count","doc":null,"default_value":"0","external_name":"row_count","restriction":""},{"name":"column_count","doc":null,"default_value":"0","external_name":"column_count","restriction":""}],"args_string":"(row_count = 0, column_count = 0)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L90","def":{"name":"empty","args":[{"name":"row_count","doc":null,"default_value":"0","external_name":"row_count","restriction":""},{"name":"column_count","doc":null,"default_value":"0","external_name":"column_count","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if (column_count != 0) && (row_count != 0)\n raise(ArgumentError.new(\"One size must be 0\"))\nend\nif column_count < 0 || row_count < 0\n raise(ArgumentError.new(\"Negative size\"))\nend\nMatrix.new(([] of Vector) * row_count, column_count)\n"}},{"id":"eye(n)-class-method","html_id":"eye(n)-class-method","name":"eye","doc":"Creates a new diagonal matrix of size `n` with ones in the diagonal\nand zeros elsewhere.","summary":"

Creates a new diagonal matrix of size n with ones in the diagonal and zeros elsewhere.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L98","def":{"name":"eye","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.diagonal([1] * n)"}},{"id":"hstack(x,*matrices)-class-method","html_id":"hstack(x,*matrices)-class-method","name":"hstack","doc":"TODO","summary":"

TODO

","abstract":false,"args":[{"name":"x","doc":null,"default_value":"","external_name":"x","restriction":""},{"name":"matrices","doc":null,"default_value":"","external_name":"matrices","restriction":""}],"args_string":"(x, *matrices)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L103","def":{"name":"hstack","args":[{"name":"x","doc":null,"default_value":"","external_name":"x","restriction":""},{"name":"matrices","doc":null,"default_value":"","external_name":"matrices","restriction":""}],"double_splat":null,"splat_index":1,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":""}},{"id":"identity(n)-class-method","html_id":"identity(n)-class-method","name":"identity","doc":"Creates a `n x n` identity matrix.","summary":"

Creates a n x n identity matrix.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L107","def":{"name":"identity","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"scalar(n, 1)"}},{"id":"row_vector(row)-class-method","html_id":"row_vector(row)-class-method","name":"row_vector","doc":"Creates a single-row matrix where the values of that row are as given in `row`.","summary":"

Creates a single-row matrix where the values of that row are as given in #row.

","abstract":false,"args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":""}],"args_string":"(row)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L112","def":{"name":"row_vector","args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.new([row], 0)"}},{"id":"rows(rows)-class-method","html_id":"rows(rows)-class-method","name":"rows","doc":"Creates a matrix where rows is an array of arrays, each of which is a row of the matrix.","summary":"

Creates a matrix where rows is an array of arrays, each of which is a row of the matrix.

","abstract":false,"args":[{"name":"rows","doc":null,"default_value":"","external_name":"rows","restriction":""}],"args_string":"(rows)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L117","def":{"name":"rows","args":[{"name":"rows","doc":null,"default_value":"","external_name":"rows","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"size = rows[0]? ? rows[0].size : 0\nrows.each do |row|\n if row.size == size\n else\n raise(\"Dimension mismatch: row size differs (#{row.size} should be #{size})\")\n end\nend\nMatrix.new(rows, size)\n"}},{"id":"scalar(n,value)-class-method","html_id":"scalar(n,value)-class-method","name":"scalar","doc":"Creates an `n` by `n` diagonal matrix where each diagonal element is value.","summary":"

Creates an n by n diagonal matrix where each diagonal element is value.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(n, value)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L126","def":{"name":"scalar","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.diagonal(Array.new(n, value))"}},{"id":"vstack(x,y)-class-method","html_id":"vstack(x,y)-class-method","name":"vstack","doc":"TODO","summary":"

TODO

","abstract":false,"args":[{"name":"x","doc":null,"default_value":"","external_name":"x","restriction":""},{"name":"y","doc":null,"default_value":"","external_name":"y","restriction":""}],"args_string":"(x, y)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L131","def":{"name":"vstack","args":[{"name":"x","doc":null,"default_value":"","external_name":"x","restriction":""},{"name":"y","doc":null,"default_value":"","external_name":"y","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":""}},{"id":"zero(row_count,column_count=row_count)-class-method","html_id":"zero(row_count,column_count=row_count)-class-method","name":"zero","doc":"Creates a zero matrix.","summary":"

Creates a zero matrix.

","abstract":false,"args":[{"name":"row_count","doc":null,"default_value":"","external_name":"row_count","restriction":""},{"name":"column_count","doc":null,"default_value":"row_count","external_name":"column_count","restriction":""}],"args_string":"(row_count, column_count = row_count)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L135","def":{"name":"zero","args":[{"name":"row_count","doc":null,"default_value":"","external_name":"row_count","restriction":""},{"name":"column_count","doc":null,"default_value":"row_count","external_name":"column_count","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"rows = Array.new(row_count) do\n Vector.new(column_count)\nend\nMatrix.new(rows, column_count)\n"}}],"constructors":[{"id":"new(rows,column_count:Int32?=nil)-class-method","html_id":"new(rows,column_count:Int32?=nil)-class-method","name":"new","doc":null,"summary":null,"abstract":false,"args":[{"name":"rows","doc":null,"default_value":"","external_name":"rows","restriction":""},{"name":"column_count","doc":null,"default_value":"nil","external_name":"column_count","restriction":"Int32 | ::Nil"}],"args_string":"(rows, column_count : Int32? = nil)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L15","def":{"name":"new","args":[{"name":"rows","doc":null,"default_value":"","external_name":"rows","restriction":""},{"name":"column_count","doc":null,"default_value":"nil","external_name":"column_count","restriction":"Int32 | ::Nil"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"_ = allocate\n_.initialize(rows, column_count)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"id":"*(other:Matrix)-instance-method","html_id":"*(other:Matrix)-instance-method","name":"*","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"args_string":"(other : Matrix)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L140","def":{"name":"*","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if column_count != other.column_count\n raise(\"Dimension mismatch\")\nend\nrows = Array.new(row_count) do |i|\n Vector.new(other.column_count) do |j|\n (0...column_count).reduce(0.0) do |vij, k|\n vij + (self[i, k] * other[k, j])\n end\n end\nend\nreturn Matrix.new(rows, other.column_count)\n"}},{"id":"*(int:Int)-instance-method","html_id":"*(int:Int)-instance-method","name":"*","doc":null,"summary":null,"abstract":false,"args":[{"name":"int","doc":null,"default_value":"","external_name":"int","restriction":"Int"}],"args_string":"(int : Int)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L154","def":{"name":"*","args":[{"name":"int","doc":null,"default_value":"","external_name":"int","restriction":"Int"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"rows = self.rows.map do |row|\n row.map do |e|\n e * int\n end\nend\nMatrix.new(rows, column_count)\n"}},{"id":"*(ind:Indexable)-instance-method","html_id":"*(ind:Indexable)-instance-method","name":"*","doc":null,"summary":null,"abstract":false,"args":[{"name":"ind","doc":null,"default_value":"","external_name":"ind","restriction":"Indexable"}],"args_string":"(ind : Indexable)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L161","def":{"name":"*","args":[{"name":"ind","doc":null,"default_value":"","external_name":"ind","restriction":"Indexable"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"m = column_vector\nr = self * m\nr.column(0)\n"}},{"id":"**(int)-instance-method","html_id":"**(int)-instance-method","name":"**","doc":null,"summary":null,"abstract":false,"args":[{"name":"int","doc":null,"default_value":"","external_name":"int","restriction":""}],"args_string":"(int)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L167","def":{"name":"**","args":[{"name":"int","doc":null,"default_value":"","external_name":"int","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if int >= 1\nelse\n raise(\"Number can not the less than 1\")\nend\nmat = self\n(int - 1).times do\n mat = mat * self\nend\nmat\n"}},{"id":"+(other:Matrix)-instance-method","html_id":"+(other:Matrix)-instance-method","name":"+","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"args_string":"(other : Matrix)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L176","def":{"name":"+","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if column_count != other.column_count\n raise(\"Dimension mismatch\")\nend\nrows = Array.new(row_count) do |i|\n Vector.new(other.column_count) do |j|\n self[i, j] + other[i, j]\n end\nend\nreturn Matrix.new(rows, other.column_count)\n"}},{"id":"+(vec:Indexable)-instance-method","html_id":"+(vec:Indexable)-instance-method","name":"+","doc":null,"summary":null,"abstract":false,"args":[{"name":"vec","doc":null,"default_value":"","external_name":"vec","restriction":"Indexable"}],"args_string":"(vec : Indexable)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L188","def":{"name":"+","args":[{"name":"vec","doc":null,"default_value":"","external_name":"vec","restriction":"Indexable"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"vec = vec.is_a?(Vector) ? vec : Vector.create(vec)\nself + (column_vector(vec))\n"}},{"id":"-(vec:Indexable)-instance-method","html_id":"-(vec:Indexable)-instance-method","name":"-","doc":null,"summary":null,"abstract":false,"args":[{"name":"vec","doc":null,"default_value":"","external_name":"vec","restriction":"Indexable"}],"args_string":"(vec : Indexable)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L205","def":{"name":"-","args":[{"name":"vec","doc":null,"default_value":"","external_name":"vec","restriction":"Indexable"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"vec = vec.is_a?(Vector) ? vec : Vector.create(vec)\nself + (column_vector(vec))\n"}},{"id":"-(other:Matrix)-instance-method","html_id":"-(other:Matrix)-instance-method","name":"-","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"args_string":"(other : Matrix)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L193","def":{"name":"-","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if column_count != other.column_count\n raise(\"Dimension mismatch\")\nend\nrows = Array.new(row_count) do |i|\n Vector.new(other.column_count) do |j|\n self[i, j] - other[i, j]\n end\nend\nreturn Matrix.new(rows, other.column_count)\n"}},{"id":"/(other:Matrix)-instance-method","html_id":"/(other:Matrix)-instance-method","name":"/","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"args_string":"(other : Matrix)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L210","def":{"name":"/","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"self * other.inverse"}},{"id":"/(vec:Indexable)-instance-method","html_id":"/(vec:Indexable)-instance-method","name":"/","doc":null,"summary":null,"abstract":false,"args":[{"name":"vec","doc":null,"default_value":"","external_name":"vec","restriction":"Indexable"}],"args_string":"(vec : Indexable)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L214","def":{"name":"/","args":[{"name":"vec","doc":null,"default_value":"","external_name":"vec","restriction":"Indexable"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"rows = self.rows.map do |row|\n row.map do |e|\n e / other\n end\nend\nreturn new_matrix(rows, column_count)\n"}},{"id":"==(other:Matrix)-instance-method","html_id":"==(other:Matrix)-instance-method","name":"==","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"args_string":"(other : Matrix)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L221","def":{"name":"==","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if (Matrix === other) && (column_count == other.column_count)\nelse\n return false\nend\nrows == other.rows\n"}},{"id":"[](row:Int,col:Int)-instance-method","html_id":"[](row:Int,col:Int)-instance-method","name":"[]","doc":"Returns element `(row, col)` of the matrix. Throws error on index error.","summary":"

Returns element (row, col) of the matrix.

","abstract":false,"args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":"Int"},{"name":"col","doc":null,"default_value":"","external_name":"col","restriction":"Int"}],"args_string":"(row : Int, col : Int)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L228","def":{"name":"[]","args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":"Int"},{"name":"col","doc":null,"default_value":"","external_name":"col","restriction":"Int"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"self[row][col]"}},{"id":"[]?(row:Int,col:Int)-instance-method","html_id":"[]?(row:Int,col:Int)-instance-method","name":"[]?","doc":"Returns element `(row, col)` of the matrix, or nil if the index is not found.","summary":"

Returns element (row, col) of the matrix, or nil if the index is not found.

","abstract":false,"args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":"Int"},{"name":"col","doc":null,"default_value":"","external_name":"col","restriction":"Int"}],"args_string":"(row : Int, col : Int)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L233","def":{"name":"[]?","args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":"Int"},{"name":"col","doc":null,"default_value":"","external_name":"col","restriction":"Int"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"v = fetch(row) do\n nil\nend\nif v.nil?\nelse\n v[col]?\nend\n"}},{"id":"adjugate-instance-method","html_id":"adjugate-instance-method","name":"adjugate","doc":"Returns the adjugate of the matrix.","summary":"

Returns the adjugate of the matrix.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L239","def":{"name":"adjugate","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if square?\nelse\n raise(\"Dimention mismatch: `Matrix#adjugate` requires a square matrix.\")\nend\nMatrix.build(row_count, column_count) do |row, column|\n cofactor(column, row)\nend\n"}},{"id":"cofactor(row,column)-instance-method","html_id":"cofactor(row,column)-instance-method","name":"cofactor","doc":"Returns the (row, column) cofactor which is obtained by multiplying the first minor by (-1)**(row + column)","summary":"

Returns the (row, column) cofactor which is obtained by multiplying the first minor by (-1)**(row + column)

","abstract":false,"args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":""},{"name":"column","doc":null,"default_value":"","external_name":"column","restriction":""}],"args_string":"(row, column)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L247","def":{"name":"cofactor","args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":""},{"name":"column","doc":null,"default_value":"","external_name":"column","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if empty?\n raise(\"cofactor of empty matrix is not defined\")\nend\nif square?\nelse\n raise(\"Dimention mismatch: `Matrix#cofactor` requires a square matrix.\")\nend\ndet_of_minor = (first_minor(row, column)).determinant\ndet_of_minor * ((-1.0) ** (row + column))\n"}},{"id":"column(j,&block)-instance-method","html_id":"column(j,&block)-instance-method","name":"column","doc":"Iterates over the specified column in the matrix, returning the Vector's items.","summary":"

Iterates over the specified column in the matrix, returning the Vector's items.

","abstract":false,"args":[{"name":"j","doc":null,"default_value":"","external_name":"j","restriction":""}],"args_string":"(j, &block)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L274","def":{"name":"column","args":[{"name":"j","doc":null,"default_value":"","external_name":"j","restriction":""}],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"if j >= column_count || j < (-column_count)\n return self\nend\nrow_count.times do |i|\n yield rows[i][j]\nend\nself\n"}},{"id":"column(j)-instance-method","html_id":"column(j)-instance-method","name":"column","doc":"Returns column vector number `j` of the matrix as a `Vector` (starting at 0 like an array).","summary":"

Returns column vector number j of the matrix as a Vector (starting at 0 like an array).

","abstract":false,"args":[{"name":"j","doc":null,"default_value":"","external_name":"j","restriction":""}],"args_string":"(j)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L265","def":{"name":"column","args":[{"name":"j","doc":null,"default_value":"","external_name":"j","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if j >= column_count || j < (-column_count)\n raise(\"Index out of range\")\nend\ncol = Array(Float64).new(row_count) do |i|\n rows[i][j]\nend\nVector.create(col)\n"}},{"id":"column?(j)-instance-method","html_id":"column?(j)-instance-method","name":"column?","doc":"Returns column vector number `j` of the matrix as a `Vector` (starting at 0 like an array).","summary":"

Returns column vector number j of the matrix as a Vector (starting at 0 like an array).

","abstract":false,"args":[{"name":"j","doc":null,"default_value":"","external_name":"j","restriction":""}],"args_string":"(j)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L256","def":{"name":"column?","args":[{"name":"j","doc":null,"default_value":"","external_name":"j","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if j >= column_count || j < (-column_count)\n return nil\nend\ncol = Array(Float64).new(row_count) do |i|\n rows[i][j]\nend\nVector.create(col)\n"}},{"id":"column_count:Int32-instance-method","html_id":"column_count:Int32-instance-method","name":"column_count","doc":null,"summary":null,"abstract":false,"args":[],"args_string":" : Int32","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L11","def":{"name":"column_count","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Int32","visibility":"Public","body":"@column_count"}},{"id":"column_vectors-instance-method","html_id":"column_vectors-instance-method","name":"column_vectors","doc":"Returns an array of the column vectors of the matrix. See `Vector`.","summary":"

Returns an array of the column vectors of the matrix.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L283","def":{"name":"column_vectors","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Array(Vector).new(column_count) do |i|\n column(i)\nend"}},{"id":"determinant-instance-method","html_id":"determinant-instance-method","name":"determinant","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L354","def":{"name":"determinant","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if square?\nelse\n raise(\"Dimention mismatch: `Matrix#determinant` requires a square matrix.\")\nend\nm = rows\ncase row_count\nwhen 0\n +1\nwhen 1\n +m[0][0]\nwhen 2\n ((+m[0][0]) * m[1][1]) - (m[0][1] * m[1][0])\nwhen 3\n m0, m1, m2 = m\n (((((((+m0[0]) * m1[1]) * m2[2]) - ((m0[0] * m1[2]) * m2[1])) - ((m0[1] * m1[0]) * m2[2])) + ((m0[1] * m1[2]) * m2[0])) + ((m0[2] * m1[0]) * m2[1])) - ((m0[2] * m1[1]) * m2[0])\nwhen 4\n m0, m1, m2, m3 = m\n ((((((((((((((((((((((((((+m0[0]) * m1[1]) * m2[2]) * m3[3]) - (((m0[0] * m1[1]) * m2[3]) * m3[2])) - (((m0[0] * m1[2]) * m2[1]) * m3[3])) + (((m0[0] * m1[2]) * m2[3]) * m3[1])) + (((m0[0] * m1[3]) * m2[1]) * m3[2])) - (((m0[0] * m1[3]) * m2[2]) * m3[1])) - (((m0[1] * m1[0]) * m2[2]) * m3[3])) + (((m0[1] * m1[0]) * m2[3]) * m3[2])) + (((m0[1] * m1[2]) * m2[0]) * m3[3])) - (((m0[1] * m1[2]) * m2[3]) * m3[0])) - (((m0[1] * m1[3]) * m2[0]) * m3[2])) + (((m0[1] * m1[3]) * m2[2]) * m3[0])) + (((m0[2] * m1[0]) * m2[1]) * m3[3])) - (((m0[2] * m1[0]) * m2[3]) * m3[1])) - (((m0[2] * m1[1]) * m2[0]) * m3[3])) + (((m0[2] * m1[1]) * m2[3]) * m3[0])) + (((m0[2] * m1[3]) * m2[0]) * m3[1])) - (((m0[2] * m1[3]) * m2[1]) * m3[0])) - (((m0[3] * m1[0]) * m2[1]) * m3[2])) + (((m0[3] * m1[0]) * m2[2]) * m3[1])) + (((m0[3] * m1[1]) * m2[0]) * m3[2])) - (((m0[3] * m1[1]) * m2[2]) * m3[0])) - (((m0[3] * m1[2]) * m2[0]) * m3[1])) + (((m0[3] * m1[2]) * m2[1]) * m3[0])\nelse\n determinant_bareiss\nend\n"}},{"id":"first_minor(row,column)-instance-method","html_id":"first_minor(row,column)-instance-method","name":"first_minor","doc":null,"summary":null,"abstract":false,"args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":""},{"name":"column","doc":null,"default_value":"","external_name":"column","restriction":""}],"args_string":"(row, column)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L429","def":{"name":"first_minor","args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":""},{"name":"column","doc":null,"default_value":"","external_name":"column","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if empty?\n raise(\"first_minor of empty matrix is not defined\")\nend\nif 0 <= row && row < row_count\nelse\n raise(ArgumentError.new(\"invalid row (#{row.inspect} for 0..#{row_count - 1})\"))\nend\nif 0 <= column && column < column_count\nelse\n raise(ArgumentError.new(\"invalid column (#{column.inspect} for 0..#{column_count - 1})\"))\nend\narrays = to_a.map(&.to_a)\narrays.delete_at(row)\narrays.each do |array|\n array.delete_at(column)\nend\nMatrix.new(arrays, column_count - 1)\n"}},{"id":"inverse-instance-method","html_id":"inverse-instance-method","name":"inverse","doc":"Returns the inverse of the matrix.","summary":"

Returns the inverse of the matrix.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L304","def":{"name":"inverse","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if square?\nelse\n if square?\n else\n raise(\"Dimention mismatch: `Matrix#inverse` requires a square matrix.\")\n end\nend\n(Matrix.identity(row_count)).inverse_from(self)\n"}},{"id":"laplace_expansion(*,row=nil,column=nil)-instance-method","html_id":"laplace_expansion(*,row=nil,column=nil)-instance-method","name":"laplace_expansion","doc":"Returns the Laplace expansion along given row or column.","summary":"

Returns the Laplace expansion along given row or column.

","abstract":false,"args":[{"name":"","doc":null,"default_value":"","external_name":"","restriction":""},{"name":"row","doc":null,"default_value":"nil","external_name":"row","restriction":""},{"name":"column","doc":null,"default_value":"nil","external_name":"column","restriction":""}],"args_string":"(*, row = nil, column = nil)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L450","def":{"name":"laplace_expansion","args":[{"name":"","doc":null,"default_value":"","external_name":"","restriction":""},{"name":"row","doc":null,"default_value":"nil","external_name":"row","restriction":""},{"name":"column","doc":null,"default_value":"nil","external_name":"column","restriction":""}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"num = row || column\nif (!num) || (row && column)\n raise(ArgumentError.new(\"exactly one the row or column arguments must be specified\"))\nend\nif square?\nelse\n raise(\"Dimention mismatch: `Matrix#determinant` requires a square matrix.\")\nend\nif empty?\n raise(\"laplace_expansion of empty matrix is not defined\")\nend\nif 0 <= num && num < row_count\nelse\n raise(ArgumentError.new(\"invalid num (#{num.inspect} for 0..#{row_count - 1})\"))\nend\nif row\n (row(num)).map_with_index do |e, k|\n e * (cofactor(num, k))\n end.reduce(&.+)\nelse\n (column(num)).map_with_index do |e, k|\n e * (cofactor(k, num))\n end.reduce(&.+)\nend\n"}},{"id":"pretty_print(pp):Nil-instance-method","html_id":"pretty_print(pp):Nil-instance-method","name":"pretty_print","doc":null,"summary":null,"abstract":false,"args":[{"name":"pp","doc":null,"default_value":"","external_name":"pp","restriction":""}],"args_string":"(pp) : Nil","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L516","def":{"name":"pretty_print","args":[{"name":"pp","doc":null,"default_value":"","external_name":"pp","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Nil","visibility":"Public","body":"pp.list(\"[\", self, \"]\") do |vec|\n pp.group do\n vec.to_a.pretty_print(pp)\n end\nend"}},{"id":"row(i,&block)-instance-method","html_id":"row(i,&block)-instance-method","name":"row","doc":null,"summary":null,"abstract":false,"args":[{"name":"i","doc":null,"default_value":"","external_name":"i","restriction":""}],"args_string":"(i, &block)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L475","def":{"name":"row","args":[{"name":"i","doc":null,"default_value":"","external_name":"i","restriction":""}],"double_splat":null,"splat_index":null,"yields":0,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":""},"return_type":"","visibility":"Public","body":"(@rows.fetch(i) do\n return self\nend).each(&block)\nself\n"}},{"id":"row(i)-instance-method","html_id":"row(i)-instance-method","name":"row","doc":null,"summary":null,"abstract":false,"args":[{"name":"i","doc":null,"default_value":"","external_name":"i","restriction":""}],"args_string":"(i)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L480","def":{"name":"row","args":[{"name":"i","doc":null,"default_value":"","external_name":"i","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.create(rows.fetch(i) do\n [] of Float64\nend)"}},{"id":"row_count:Int32-instance-method","html_id":"row_count:Int32-instance-method","name":"row_count","doc":null,"summary":null,"abstract":false,"args":[],"args_string":" : Int32","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L13","def":{"name":"row_count","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Int32","visibility":"Public","body":"@row_count"}},{"id":"rows-instance-method","html_id":"rows-instance-method","name":"rows","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L484","def":{"name":"rows","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"rows = [] of Vector\nrow_count.times do |i|\n rows << self[i - 1]\nend\nrows\n"}},{"id":"square?-instance-method","html_id":"square?-instance-method","name":"square?","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L492","def":{"name":"square?","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"row_count == column_count"}},{"id":"to_s(io)-instance-method","html_id":"to_s(io)-instance-method","name":"to_s","doc":null,"summary":null,"abstract":false,"args":[{"name":"io","doc":null,"default_value":"","external_name":"io","restriction":""}],"args_string":"(io)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L502","def":{"name":"to_s","args":[{"name":"io","doc":null,"default_value":"","external_name":"io","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if empty?\n \"Matrix.empty(#{row_count}, #{column_count})\"\nelse\n io << \"Matrix[\"\n io << (map do |row|\n (\"{\" + (row.to_a.map do |e|\n e.to_s\n end.join(\", \"))) + \"}\"\n end.join(\", \"))\n io << \"]\"\nend"}},{"id":"transpose-instance-method","html_id":"transpose-instance-method","name":"transpose","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L496","def":{"name":"transpose","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if row_count.zero?\n return Matrix.empty(column_count, 0)\nend\ntransposed = rows.map do |v|\n v.to_a\nend.transpose\nMatrix.new(transposed, row_count)\n"}},{"id":"unsafe_fetch(index:Int)-instance-method","html_id":"unsafe_fetch(index:Int)-instance-method","name":"unsafe_fetch","doc":null,"summary":null,"abstract":false,"args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"}],"args_string":"(index : Int)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L525","def":{"name":"unsafe_fetch","args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@buffer[index]"}}],"macros":[],"types":[]},{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra/NDArray","path":"Apatite/LinearAlgebra/NDArray.html","kind":"class","full_name":"Apatite::LinearAlgebra::NDArray","name":"NDArray","abstract":false,"superclass":{"html_id":"github.com/watzon/apatite/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"github.com/watzon/apatite/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"github.com/watzon/apatite/Indexable","kind":"module","full_name":"Indexable","name":"Indexable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Iterable","kind":"module","full_name":"Iterable","name":"Iterable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"github.com/watzon/apatite/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"apatite/linear_algebra/ndarray.cr","line_number":2,"url":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/ndarray.cr"}],"repository_name":"github.com/watzon/apatite","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[{"html_id":"github.com/watzon/apatite/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Indexable","kind":"module","full_name":"Indexable","name":"Indexable"}],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra","kind":"module","full_name":"Apatite::LinearAlgebra","name":"LinearAlgebra"},"doc":null,"summary":null,"class_methods":[],"constructors":[{"id":"new(data:Array(Number),shape:Array(Int32)?=nil)-class-method","html_id":"new(data:Array(Number),shape:Array(Int32)?=nil)-class-method","name":"new","doc":null,"summary":null,"abstract":false,"args":[{"name":"data","doc":null,"default_value":"","external_name":"data","restriction":"Array(Number)"},{"name":"shape","doc":null,"default_value":"nil","external_name":"shape","restriction":"Array(Int32) | ::Nil"}],"args_string":"(data : Array(Number), shape : Array(Int32)? = nil)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/ndarray.cr#L18","def":{"name":"new","args":[{"name":"data","doc":null,"default_value":"","external_name":"data","restriction":"Array(Number)"},{"name":"shape","doc":null,"default_value":"nil","external_name":"shape","restriction":"Array(Int32) | ::Nil"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"_ = allocate\n_.initialize(data, shape)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"id":"[](*args,**options)-instance-method","html_id":"[](*args,**options)-instance-method","name":"[]","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/ndarray.cr#L11","def":{"name":"[]","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@data[*args, **options]"}},{"id":"[](*args,**options,&block)-instance-method","html_id":"[](*args,**options,&block)-instance-method","name":"[]","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options, &block)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/ndarray.cr#L11","def":{"name":"[]","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"@data[*args, **options] do |*yield_args|\n yield *yield_args\nend"}},{"id":"[]=(*args,**options)-instance-method","html_id":"[]=(*args,**options)-instance-method","name":"[]=","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/ndarray.cr#L13","def":{"name":"[]=","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@data[*args] = **options"}},{"id":"[]?(*args,**options)-instance-method","html_id":"[]?(*args,**options)-instance-method","name":"[]?","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/ndarray.cr#L12","def":{"name":"[]?","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@data[*args, **options]?"}},{"id":"[]?(*args,**options,&block)-instance-method","html_id":"[]?(*args,**options,&block)-instance-method","name":"[]?","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options, &block)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/ndarray.cr#L12","def":{"name":"[]?","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"@data[*args, **options]? do |*yield_args|\n yield *yield_args\nend"}},{"id":"abs-instance-method","html_id":"abs-instance-method","name":"abs","doc":"Returns the absolute value of every item in the array","summary":"

Returns the absolute value of every item in the array

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/ndarray.cr#L24","def":{"name":"abs","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"map do |e|\n e.abs\nend"}},{"id":"acos-instance-method","html_id":"acos-instance-method","name":"acos","doc":"Returns the arccosine of each element in the current array.","summary":"

Returns the arccosine of each element in the current array.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/ndarray.cr#L29","def":{"name":"acos","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":""}},{"id":"data:Array(Float64)-instance-method","html_id":"data:Array(Float64)-instance-method","name":"data","doc":null,"summary":null,"abstract":false,"args":[],"args_string":" : Array(Float64)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/ndarray.cr#L9","def":{"name":"data","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Array(Float64)","visibility":"Public","body":"@data"}},{"id":"shape:Array(Int32)-instance-method","html_id":"shape:Array(Int32)-instance-method","name":"shape","doc":null,"summary":null,"abstract":false,"args":[],"args_string":" : Array(Int32)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/ndarray.cr#L11","def":{"name":"shape","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Array(Int32)","visibility":"Public","body":"@shape"}},{"id":"size(*args,**options)-instance-method","html_id":"size(*args,**options)-instance-method","name":"size","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/ndarray.cr#L16","def":{"name":"size","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@data.size(*args, **options)"}},{"id":"size(*args,**options,&block)-instance-method","html_id":"size(*args,**options,&block)-instance-method","name":"size","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options, &block)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/ndarray.cr#L16","def":{"name":"size","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"@data.size(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"id":"to_unsafe(*args,**options)-instance-method","html_id":"to_unsafe(*args,**options)-instance-method","name":"to_unsafe","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/ndarray.cr#L15","def":{"name":"to_unsafe","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@data.to_unsafe(*args, **options)"}},{"id":"to_unsafe(*args,**options,&block)-instance-method","html_id":"to_unsafe(*args,**options,&block)-instance-method","name":"to_unsafe","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options, &block)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/ndarray.cr#L15","def":{"name":"to_unsafe","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"@data.to_unsafe(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"id":"unsafe_fetch(*args,**options)-instance-method","html_id":"unsafe_fetch(*args,**options)-instance-method","name":"unsafe_fetch","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/ndarray.cr#L14","def":{"name":"unsafe_fetch","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@data.unsafe_fetch(*args, **options)"}},{"id":"unsafe_fetch(*args,**options,&block)-instance-method","html_id":"unsafe_fetch(*args,**options,&block)-instance-method","name":"unsafe_fetch","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options, &block)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/ndarray.cr#L14","def":{"name":"unsafe_fetch","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"@data.unsafe_fetch(*args, **options) do |*yield_args|\n yield *yield_args\nend"}}],"macros":[],"types":[]},{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra/Vector","path":"Apatite/LinearAlgebra/Vector.html","kind":"class","full_name":"Apatite::LinearAlgebra::Vector","name":"Vector","abstract":false,"superclass":{"html_id":"github.com/watzon/apatite/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"github.com/watzon/apatite/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"github.com/watzon/apatite/Indexable","kind":"module","full_name":"Indexable","name":"Indexable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Iterable","kind":"module","full_name":"Iterable","name":"Iterable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"github.com/watzon/apatite/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"apatite/linear_algebra/vector.cr","line_number":4,"url":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr"}],"repository_name":"github.com/watzon/apatite","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[{"id":"I","name":"I","value":"Vector.create([1.0, 0.0, 0.0])","doc":"Cartesian unit vector I","summary":"

Cartesian unit vector I

"},{"id":"J","name":"J","value":"Vector.create([0.0, 1.0, 0.0])","doc":"Cartesian unit vector J","summary":"

Cartesian unit vector J

"},{"id":"K","name":"K","value":"Vector.create([0.0, 0.0, 1.0])","doc":"Cartesian unit vector K","summary":"

Cartesian unit vector K

"}],"included_modules":[{"html_id":"github.com/watzon/apatite/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Indexable","kind":"module","full_name":"Indexable","name":"Indexable"}],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra","kind":"module","full_name":"Apatite::LinearAlgebra","name":"LinearAlgebra"},"doc":"Represents a mathematical vector, and also constitutes a row or column\nof a `Matrix`","summary":"

Represents a mathematical vector, and also constitutes a row or column of a Matrix

","class_methods":[{"id":"[](*array)-class-method","html_id":"[](*array)-class-method","name":"[]","doc":null,"summary":null,"abstract":false,"args":[{"name":"array","doc":null,"default_value":"","external_name":"array","restriction":""}],"args_string":"(*array)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L156","def":{"name":"[]","args":[{"name":"array","doc":null,"default_value":"","external_name":"array","restriction":""}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.create(array)"}},{"id":"basis(size,index)-class-method","html_id":"basis(size,index)-class-method","name":"basis","doc":"Returns a standard basis n-vector.","summary":"

Returns a standard basis n-vector.

","abstract":false,"args":[{"name":"size","doc":null,"default_value":"","external_name":"size","restriction":""},{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":""}],"args_string":"(size, index)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L138","def":{"name":"basis","args":[{"name":"size","doc":null,"default_value":"","external_name":"size","restriction":""},{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if size < 1\n raise(ArgumentError.new(\"invalid size (#{size} for 1..)\"))\nend\nif 0 <= index && index < size\nelse\n raise(ArgumentError.new(\"invalid index (#{index} for 0...#{size})\"))\nend\nvec = Vector.new(size, 0.0)\nvec[index] = 1.0\nvec\n"}},{"id":"create(elements:Indexable(Number))-class-method","html_id":"create(elements:Indexable(Number))-class-method","name":"create","doc":"Creates a new `Vector` from the elements of another `Indexable`\ncollection.\n\n```\nVector.create([1, 2, 3]) # Vector{1.0, 2.0, 3.0}\n```","summary":"

Creates a new Vector from the elements of another Indexable collection.

","abstract":false,"args":[{"name":"elements","doc":null,"default_value":"","external_name":"elements","restriction":"Indexable(Number)"}],"args_string":"(elements : Indexable(Number))","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L118","def":{"name":"create","args":[{"name":"elements","doc":null,"default_value":"","external_name":"elements","restriction":"Indexable(Number)"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"vec = Vector.new\nelements.each do |el|\n vec.push(el.to_f64)\nend\nvec\n"}},{"id":"ones(n)-class-method","html_id":"ones(n)-class-method","name":"ones","doc":"Create a new vector of size `n` filled with ones.","summary":"

Create a new vector of size n filled with ones.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L152","def":{"name":"ones","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.new(n, 1.0)"}},{"id":"random(n,range=nil)-class-method","html_id":"random(n,range=nil)-class-method","name":"random","doc":"Creates a new `Vector` of size `n` filled with random numbers. A `range`\ncan optionally be passed in if you want to limit the random numbers\nto a given range.","summary":"

Creates a new Vector of size n filled with random numbers.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""},{"name":"range","doc":null,"default_value":"nil","external_name":"range","restriction":""}],"args_string":"(n, range = nil)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L129","def":{"name":"random","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""},{"name":"range","doc":null,"default_value":"nil","external_name":"range","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"vec = Vector.new(n)\nn.times do\n vec.push(rand((range || -1e+1)..1e+1))\nend\nvec\n"}},{"id":"zeros(n)-class-method","html_id":"zeros(n)-class-method","name":"zeros","doc":"Create a new vector of size `n` filled with zeros.","summary":"

Create a new vector of size n filled with zeros.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L147","def":{"name":"zeros","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.new(n, 0.0)"}}],"constructors":[{"id":"build(capacity:Int,&block):self-class-method","html_id":"build(capacity:Int,&block):self-class-method","name":"build","doc":"Creates a new `Vector`, allocating an internal buffer with the given *capacity*,\nand yielding that buffer. The given block must return the desired size of the vector.\n\nThis method is **unsafe**.\n\n```\nVector.build(3) do |buffer|\n LibSome.fill_buffer_and_return_number_of_elements_filled(buffer)\nend\n```","summary":"

Creates a new Vector, allocating an internal buffer with the given capacity, and yielding that buffer.

","abstract":false,"args":[{"name":"capacity","doc":null,"default_value":"","external_name":"capacity","restriction":"Int"}],"args_string":"(capacity : Int, &block) : self","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L106","def":{"name":"build","args":[{"name":"capacity","doc":null,"default_value":"","external_name":"capacity","restriction":"Int"}],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"self","visibility":"Public","body":"vec = Vector.new(capacity)\nvec.size = (yield vec.to_unsafe).to_i\nvec\n"}},{"id":"new(size:Int,value:Float64)-class-method","html_id":"new(size:Int,value:Float64)-class-method","name":"new","doc":"Creates a new `Vector` of the given *size* filled with the same *value* in each position.\n\n```\nVector.new(3, 1.0) # => Vector{1.0, 1.0, 1.0}\n```","summary":"

Creates a new Vector of the given size filled with the same value in each position.

","abstract":false,"args":[{"name":"size","doc":null,"default_value":"","external_name":"size","restriction":"Int"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":"Float64"}],"args_string":"(size : Int, value : Float64)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L63","def":{"name":"new","args":[{"name":"size","doc":null,"default_value":"","external_name":"size","restriction":"Int"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":"Float64"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"_ = allocate\n_.initialize(size, value)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"id":"new(initial_capacity:Int)-class-method","html_id":"new(initial_capacity:Int)-class-method","name":"new","doc":"Creates a new empty `Vector` backed by a buffer that is initially\n`initial_capacity` big.\n\nThe *initial_capacity* is useful to avoid unnecessary reallocations\nof the internal buffer in case of growth. If you have an estimate\nof the maximum number of elements an vector will hold, the vector should\nbe initialized with that capacity for improved performance.\n\n```\nvec = Vector.new(5)\nvec.size # => 0\n```","summary":"

Creates a new empty Vector backed by a buffer that is initially initial_capacity big.

","abstract":false,"args":[{"name":"initial_capacity","doc":null,"default_value":"","external_name":"initial_capacity","restriction":"Int"}],"args_string":"(initial_capacity : Int)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L43","def":{"name":"new","args":[{"name":"initial_capacity","doc":null,"default_value":"","external_name":"initial_capacity","restriction":"Int"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"_ = allocate\n_.initialize(initial_capacity)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"id":"new-class-method","html_id":"new-class-method","name":"new","doc":"Create a new empty `Vector`.","summary":"

Create a new empty Vector.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L25","def":{"name":"new","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"_ = allocate\n_.initialize\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"id":"new(size:Int,&block:Int32->Float64)-class-method","html_id":"new(size:Int,&block:Int32->Float64)-class-method","name":"new","doc":"Creates a new `Vector` of the given *size* and invokes the given block once\nfor each index of `self`, assigning the block's value in that index.\n\n```\nVector.new(3) { |i| (i + 1.0) ** 2.0 } # => Vector{1.0, 4.0, 9.0}\n\nvec = Vector.new(3) { 5.0 }\nvec # => Vector{5.0, 5.0, 5.0}\n```","summary":"

Creates a new Vector of the given size and invokes the given block once for each index of self, assigning the block's value in that index.

","abstract":false,"args":[{"name":"size","doc":null,"default_value":"","external_name":"size","restriction":"Int"}],"args_string":"(size : Int, &block : Int32 -> Float64)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L87","def":{"name":"new","args":[{"name":"size","doc":null,"default_value":"","external_name":"size","restriction":"Int"}],"double_splat":null,"splat_index":null,"yields":1,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":"(Int32 -> Float64)"},"return_type":"","visibility":"Public","body":"Vector.build(size) do |buffer|\n size.to_i.times do |i|\n buffer[i] = yield i\n end\n size\nend"}}],"instance_methods":[{"id":"*(other)-instance-method","html_id":"*(other)-instance-method","name":"*","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"args_string":"(other)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L370","def":{"name":"*","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"multiply(other)"}},{"id":"+(other)-instance-method","html_id":"+(other)-instance-method","name":"+","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"args_string":"(other)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L362","def":{"name":"+","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"add(other)"}},{"id":"-(other)-instance-method","html_id":"-(other)-instance-method","name":"-","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"args_string":"(other)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L366","def":{"name":"-","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"subtract(other)"}},{"id":"<<(value:Float64)-instance-method","html_id":"<<(value:Float64)-instance-method","name":"<<","doc":"Alias for `#push`","summary":"

Alias for #push

","abstract":false,"args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":"Float64"}],"args_string":"(value : Float64)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L349","def":{"name":"<<","args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":"Float64"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"push(value)"}},{"id":"(other)-instance-method","html_id":"(other)-instance-method","name":"<=>","doc":"Combined comparison operator. Returns *0* if `self` equals *other*, *1* if\n`self` is greater than *other* and *-1* if `self` is smaller than *other*.\n\nIt compares the elements of both vectors in the same position using the\n`<=>` operator. As soon as one of such comparisons returns a non-zero\nvalue, that result is the return value of the comparison.\n\nIf all elements are equal, the comparison is based on the size of the vectors.\n\n```\nVector{8.0} <=> Vector(1.0, 2.0, 3.0} # => 1\nVector{2.0} <=> Vector{4.0, 2.0, 3.0} # => -1\nVector{1.0, 2.0} <=> Vector{1.0, 2.0} # => 0\n```","summary":"

Combined comparison operator.

","abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"args_string":"(other)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L339","def":{"name":"<=>","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"min_size = Math.min(size, other.size)\n0.upto(min_size - 1) do |i|\n n = @buffer[i] <=> other.to_unsafe[i]\n if n != 0\n return n\n end\nend\nsize <=> other.size\n"}},{"id":"==(other:Vector)-instance-method","html_id":"==(other:Vector)-instance-method","name":"==","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Vector"}],"args_string":"(other : Vector)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L353","def":{"name":"==","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Vector"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"equals?(other) do |x, y|\n x == y\nend"}},{"id":"[](start:Int,count:Int)-instance-method","html_id":"[](start:Int,count:Int)-instance-method","name":"[]","doc":"Returns count or less (if there aren't enough) elements starting at the\ngiven start index.\n\nNegative indices count backward from the end of the vector (-1 is the last\nelement). Additionally, an empty vector is returned when the starting index\nfor an element range is at the end of the vector.\n\nRaises `IndexError` if the starting index is out of range.\n\n```\nv = Vector{1.0, 2.0, 3.0, 4.0, 5.0}\nv[1, 3] # => Vector{2.0, 3.0, 4.0}\nv[6, 10] # raise IndexError\n```","summary":"

Returns count or less (if there aren't enough) elements starting at the given start index.

","abstract":false,"args":[{"name":"start","doc":null,"default_value":"","external_name":"start","restriction":"Int"},{"name":"count","doc":null,"default_value":"","external_name":"count","restriction":"Int"}],"args_string":"(start : Int, count : Int)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L191","def":{"name":"[]","args":[{"name":"start","doc":null,"default_value":"","external_name":"start","restriction":"Int"},{"name":"count","doc":null,"default_value":"","external_name":"count","restriction":"Int"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if count < 0\n raise(ArgumentError.new(\"Negative count: #{count}\"))\nend\nif start == size\n return Vector.new\nend\nif start < 0\n start = start + size\nend\nif 0 <= start && start <= size\nelse\n raise(IndexError.new)\nend\nif count == 0\n return Vector.new\nend\ncount = Math.min(count, size - start)\nVector.build(count) do |buffer|\n buffer.copy_from(@buffer + start, count)\n count\nend\n"}},{"id":"[](range:Range(Int,Int))-instance-method","html_id":"[](range:Range(Int,Int))-instance-method","name":"[]","doc":"Returns all elements that are within the given range.\n\nNegative indices count backward from the end of the vector (-1 is the last\nelement). Additionally, an empty vector is returned when the starting index\nfor an element range is at the end of the vector.\n\nRaises `IndexError` if the starting index is out of range.\n\n```\nv = Vector{1.0, 2.0, 3.0, 4.0, 5.0}\nv[1..3] # => Vector{2.0, 3.0, 4.0}\nv[6..10] # raise IndexError\n```","summary":"

Returns all elements that are within the given range.

","abstract":false,"args":[{"name":"range","doc":null,"default_value":"","external_name":"range","restriction":"Range(Int, Int)"}],"args_string":"(range : Range(Int, Int))","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L173","def":{"name":"[]","args":[{"name":"range","doc":null,"default_value":"","external_name":"range","restriction":"Range(Int, Int)"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"self[*Indexable.range_to_index_and_count(range, size)]"}},{"id":"[]=(index:Int,count:Int,values:Vector)-instance-method","html_id":"[]=(index:Int,count:Int,values:Vector)-instance-method","name":"[]=","doc":"Replaces a subrange with the elements of the given vector.\n\n```\nvec = Vector{1.0, 2.0, 3.0, 4.0, 5.0}\nvec[1, 3] = Vector{6.0, 7.0, 8.0}\nvec # = Vector{1.0, 6.0, 7.0, 8.0, 5.0}\n\nvec = Vector{1.0, 2.0, 3.0, 4.0, 5.0}\nvec[1, 3] = Vector{6.0, 7.0}\nvec # = Vector{1.0, 6.0, 7.0, 5.0}\n```","summary":"

Replaces a subrange with the elements of the given vector.

","abstract":false,"args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"},{"name":"count","doc":null,"default_value":"","external_name":"count","restriction":"Int"},{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":"Vector"}],"args_string":"(index : Int, count : Int, values : Vector)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L297","def":{"name":"[]=","args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"},{"name":"count","doc":null,"default_value":"","external_name":"count","restriction":"Int"},{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":"Vector"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if count < 0\n raise(ArgumentError.new(\"Negative count: #{count}\"))\nend\nindex = check_index_out_of_bounds(index)\ncount = ((index + count) <= size) ? count : size - index\ndiff = values.size - count\nif diff == 0\n (@buffer + index).copy_from(values.to_unsafe, values.size)\nelse\n if diff < 0\n diff = -diff\n (@buffer + index).copy_from(values.to_unsafe, values.size)\n ((@buffer + index) + values.size).move_from((@buffer + index) + count, (size - index) - count)\n ((@buffer + @size) - diff).clear(diff)\n @size = @size - diff\n else\n resize_to_capacity(Math.pw2ceil(@size + diff))\n ((@buffer + index) + values.size).move_from((@buffer + index) + count, (size - index) - count)\n (@buffer + index).copy_from(values.to_unsafe, values.size)\n @size = @size + diff\n end\nend\nvalues\n"}},{"id":"[]=(index:Int,count:Int,value)-instance-method","html_id":"[]=(index:Int,count:Int,value)-instance-method","name":"[]=","doc":"Replaces a subrange with a single value. All elements in the range\n`index...index+count` are removed and replaced by a single element\n*value*.\n\nIf *count* is zero, *value* is inserted at *index*.\n\nNegative values of *index* count from the end of the vector.\n\n```\nvec = Vector{1.0, 2.0, 3.0, 4.0, 5.0}\nvec[1, 3] = 6.0\nvec # => Vector{1.0, 6.0, 5.0}\n\nvec = Vector{1.0, 2.0, 3.0, 4.0, 5.0}\nvec[1, 0] = 6.0\nvec # => Vector{1.0, 6.0, 2.0, 3.0, 4.0, 5.0}\n```","summary":"

Replaces a subrange with a single value.

","abstract":false,"args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"},{"name":"count","doc":null,"default_value":"","external_name":"count","restriction":"Int"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(index : Int, count : Int, value)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L248","def":{"name":"[]=","args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"},{"name":"count","doc":null,"default_value":"","external_name":"count","restriction":"Int"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if count < 0\n raise(ArgumentError.new(\"Negative count: #{count}\"))\nend\nvalue = value.to_f64\nindex = check_index_out_of_bounds(index)\ncount = ((index + count) <= size) ? count : size - index\ncase count\nwhen 0\n insert(index, value)\nwhen 1\n @buffer[index] = value\nelse\n diff = count - 1\n ((@buffer + index) + 1).move_from((@buffer + index) + count, (size - index) - count)\n ((@buffer + @size) - diff).clear(diff)\n @buffer[index] = value\n @size = @size - diff\nend\nvalue\n"}},{"id":"[]=(index:Int,value)-instance-method","html_id":"[]=(index:Int,value)-instance-method","name":"[]=","doc":"Sets the given value at the given index.\n\nNegative indices can be used to start counting from the end of the array.\nRaises `IndexError` if trying to set an element outside the array's range.\n\n```\nvec = Vector{1.0, 2.0, 3.0}\nvec[0] = 5.0\np vec # => Vec{5.0, 2.0, 3.0}\n\nvec[3] = 5.0 # raises IndexError\n```","summary":"

Sets the given value at the given index.

","abstract":false,"args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(index : Int, value)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L226","def":{"name":"[]=","args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"index = check_index_out_of_bounds(index)\n@buffer[index] = value.to_f64\n"}},{"id":"[]=(range:Range(Int,Int),value)-instance-method","html_id":"[]=(range:Range(Int,Int),value)-instance-method","name":"[]=","doc":"Replaces a subrange with a single value.\n\n```\nvec = Vector{1.0, 2.0, 3.0, 4.0, 5.0}\nvec[1..3] = 6.0\nvec # = Vector{1.0, 6.0, 5.0}\n\nvec = Vector{1.0, 2.0, 3.0, 4.0, 5.0}\nvec[1...1] = 6\nvec # = Vector{1.0, 6.0, 2.0, 3.0, 4.0, 5.0}\n```","summary":"

Replaces a subrange with a single value.

","abstract":false,"args":[{"name":"range","doc":null,"default_value":"","external_name":"range","restriction":"Range(Int, Int)"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(range : Range(Int, Int), value)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L282","def":{"name":"[]=","args":[{"name":"range","doc":null,"default_value":"","external_name":"range","restriction":"Range(Int, Int)"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"self[*Indexable.range_to_index_and_count(range, size)] = value.to_f64"}},{"id":"add(value)-instance-method","html_id":"add(value)-instance-method","name":"add","doc":"When the input is a number, this returns the result of adding\nit to all vector elements. When it's a vector, the vectors\nwill be added together.","summary":"

When the input is a number, this returns the result of adding it to all vector elements.

","abstract":false,"args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(value)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L488","def":{"name":"add","args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"run_binary_op(value) do |a, b|\n a + b\nend"}},{"id":"angle_from(vector)-instance-method","html_id":"angle_from(vector)-instance-method","name":"angle_from","doc":"Returns the angle between this vector and another in radians.\nIf the vectors are mirrored across their axes this will return `nil`.","summary":"

Returns the angle between this vector and another in radians.

","abstract":false,"args":[{"name":"vector","doc":null,"default_value":"","external_name":"vector","restriction":""}],"args_string":"(vector)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L440","def":{"name":"angle_from","args":[{"name":"vector","doc":null,"default_value":"","external_name":"vector","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"v = vector.is_a?(Vector) ? vector : Vector.create(vector)\nif size == v.size\nelse\n raise(\"Cannot compute the angle between vectors with different dimensionality\")\nend\ndot = 0_f64\nmod1 = 0_f64\nmod2 = 0_f64\n(zip(vector)).each do |x, v|\n dot = dot + (x * v)\n mod1 = mod1 + (x * x)\n mod2 = mod2 + (v * v)\nend\nmod1 = Math.sqrt(mod1)\nmod2 = Math.sqrt(mod2)\nif (mod2 * mod2) == 0\n return 0.0\nend\ntheta = (dot / (mod1 * mod2)).clamp(-1, 1)\nMath.acos(theta)\n"}},{"id":"antiparallel_to?(vector)-instance-method","html_id":"antiparallel_to?(vector)-instance-method","name":"antiparallel_to?","doc":"Returns whether the vectors are antiparallel to each other.","summary":"

Returns whether the vectors are antiparallel to each other.

","abstract":false,"args":[{"name":"vector","doc":null,"default_value":"","external_name":"vector","restriction":""}],"args_string":"(vector)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L475","def":{"name":"antiparallel_to?","args":[{"name":"vector","doc":null,"default_value":"","external_name":"vector","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"angle = angle_from(vector)\n(angle - Math::PI).abs <= Apatite.precision\n"}},{"id":"augment(elements)-instance-method","html_id":"augment(elements)-instance-method","name":"augment","doc":"Returns a new vector with the provided `elements` concatenated\non the end.","summary":"

Returns a new vector with the provided elements concatenated on the end.

","abstract":false,"args":[{"name":"elements","doc":null,"default_value":"","external_name":"elements","restriction":""}],"args_string":"(elements)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L556","def":{"name":"augment","args":[{"name":"elements","doc":null,"default_value":"","external_name":"elements","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"elements = elements.is_a?(Vector) ? elements : Vector.create(elements)\nconcat(elements)\n"}},{"id":"chomp(n)-instance-method","html_id":"chomp(n)-instance-method","name":"chomp","doc":"Returns a new vector with the first `n` elements removed from\nthe beginning.","summary":"

Returns a new vector with the first n elements removed from the beginning.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L541","def":{"name":"chomp","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"elements = [] of Float64\neach_with_index do |e, i|\n if i >= n\n elements << e\n end\nend\nVector.create(elements)\n"}},{"id":"clear-instance-method","html_id":"clear-instance-method","name":"clear","doc":"Removes all elements from self.\n\n```\nvec = Vector{1.0, 2.0, 3.0}\nvec.clear # => Vector{}\n```","summary":"

Removes all elements from self.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L782","def":{"name":"clear","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@buffer.clear(@size)\n@size = 0\nself\n"}},{"id":"clone-instance-method","html_id":"clone-instance-method","name":"clone","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L374","def":{"name":"clone","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.create(@elements.clone)"}},{"id":"concat(other:Vector)-instance-method","html_id":"concat(other:Vector)-instance-method","name":"concat","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Vector"}],"args_string":"(other : Vector)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L731","def":{"name":"concat","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Vector"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"other_size = other.size\nnew_size = size + other_size\nif new_size > @capacity\n resize_to_capacity(Math.pw2ceil(new_size))\nend\n(@buffer + @size).copy_from(other.to_unsafe, other_size)\n@size = new_size\nself\n"}},{"id":"covector-instance-method","html_id":"covector-instance-method","name":"covector","doc":"Creates a single-row matrix from this vector.","summary":"

Creates a single-row matrix from this vector.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L601","def":{"name":"covector","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.row_vector(self)"}},{"id":"cross(*vs)-instance-method","html_id":"cross(*vs)-instance-method","name":"cross","doc":"Returns the cross product of this vector with the others.\n\n```\nv1 = Vector{1.0, 0.0, 0.0}\nv2 = Vector{0.0, 1.0, 0.0}\nv1.cross(v2) => Vector{0.0, 0.0, 1.0}\n```","summary":"

Returns the cross product of this vector with the others.

","abstract":false,"args":[{"name":"vs","doc":null,"default_value":"","external_name":"vs","restriction":""}],"args_string":"(*vs)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L518","def":{"name":"cross","args":[{"name":"vs","doc":null,"default_value":"","external_name":"vs","restriction":""}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if size >= 2\nelse\n raise(\"cross product is not defined on vectors of dimension #{size}\")\nend\nif vs.size == (size - 2)\nelse\n raise(ArgumentError.new(\"wrong number of arguments (#{vs.size} for #{size - 2})\"))\nend\nvs.each do |v|\n if v.size == size\n else\n raise(\"Dimension mismatch. Vectors not all the same size.\")\n end\nend\ncase size\nwhen 2\n Vector[-@buffer[1], @buffer[0]]\nwhen 3\n v = vs[0]\n Vector[(v[2] * @buffer[1]) - (v[1] * @buffer[2]), (v[0] * @buffer[2]) - (v[2] * @buffer[0]), (v[1] * @buffer[0]) - (v[0] * @buffer[1])]\nelse\nend\n"}},{"id":"distance_from(obj)-instance-method","html_id":"distance_from(obj)-instance-method","name":"distance_from","doc":"Gets this vector's distance from the argument, when considered\na point in space.","summary":"

Gets this vector's distance from the argument, when considered a point in space.

","abstract":false,"args":[{"name":"obj","doc":null,"default_value":"","external_name":"obj","restriction":""}],"args_string":"(obj)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L629","def":{"name":"distance_from","args":[{"name":"obj","doc":null,"default_value":"","external_name":"obj","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if object.is_a?(Plane) || object.is_a?(Line)\n return object.distance_from(self)\nend\nv = elements.is_a?(Vector) ? elements.elements : elements\nif v.size == @elements.size\nelse\n return nil\nend\nsum = 0\npart = 0\neach_with_index do |x, i|\n part = x - v[i - 1]\n sum = sum + (part * part)\nend\nMath.sqrt(sum)\n"}},{"id":"dot(other)-instance-method","html_id":"dot(other)-instance-method","name":"dot","doc":"Get the scalar (dot) product of this vector with `vector`.\n\n[https://en.wikipedia.org/wiki/Scalar_product](https://en.wikipedia.org/wiki/Scalar_product)","summary":"

Get the scalar (dot) product of this vector with vector.

","abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"args_string":"(other)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L574","def":{"name":"dot","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"other = other.is_a?(Vector) ? other : Vector.create(other)\nif size == other.size\nelse\n raise(\"Cannot compute the dot product of vectors with different dimensionality\")\nend\nproduct = 0\n(0...size).each do |i|\n product = product + (self[i] * other[i])\nend\nproduct\n"}},{"id":"e(i)-instance-method","html_id":"e(i)-instance-method","name":"e","doc":"Returns the `ith` element of the vector. Returns `nil` if `i`\nis out of bounds. Indexing starts from 1.","summary":"

Returns the ith element of the vector.

","abstract":false,"args":[{"name":"i","doc":null,"default_value":"","external_name":"i","restriction":""}],"args_string":"(i)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L426","def":{"name":"e","args":[{"name":"i","doc":null,"default_value":"","external_name":"i","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"(i < 1 || i > @size) ? nil : self[i - 1]"}},{"id":"independent?(*vs)-instance-method","html_id":"independent?(*vs)-instance-method","name":"independent?","doc":"Returns true if all vectors are linearly independent.","summary":"

Returns true if all vectors are linearly independent.

","abstract":false,"args":[{"name":"vs","doc":null,"default_value":"","external_name":"vs","restriction":""}],"args_string":"(*vs)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L384","def":{"name":"independent?","args":[{"name":"vs","doc":null,"default_value":"","external_name":"vs","restriction":""}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"vs.each do |v|\n if v.size == vs.first.size\n else\n raise(\"Dimension mismatch. Vectors not all the same size.\")\n end\nend\nif vs.size > sv.first.size\n return false\nend\nMatrix[*vs].rank.equal?(vs.count)\n"}},{"id":"lies_in(plane)-instance-method","html_id":"lies_in(plane)-instance-method","name":"lies_in","doc":"Returns true if the vector is a point on the given plane.","summary":"

Returns true if the vector is a point on the given plane.

","abstract":false,"args":[{"name":"plane","doc":null,"default_value":"","external_name":"plane","restriction":""}],"args_string":"(plane)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L654","def":{"name":"lies_in","args":[{"name":"plane","doc":null,"default_value":"","external_name":"plane","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"plane.contains(self)"}},{"id":"lies_on(line)-instance-method","html_id":"lies_on(line)-instance-method","name":"lies_on","doc":"Returns true if the vector is a point on the given line","summary":"

Returns true if the vector is a point on the given line

","abstract":false,"args":[{"name":"line","doc":null,"default_value":"","external_name":"line","restriction":""}],"args_string":"(line)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L649","def":{"name":"lies_on","args":[{"name":"line","doc":null,"default_value":"","external_name":"line","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"line.contains(self)"}},{"id":"log-instance-method","html_id":"log-instance-method","name":"log","doc":"Return a new `Vector` with the log of every item in `self`.","summary":"

Return a new Vector with the log of every item in self.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L562","def":{"name":"log","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"map do |x|\n Math.log(x)\nend"}},{"id":"magnitude-instance-method","html_id":"magnitude-instance-method","name":"magnitude","doc":"Returns the magnitude/euclidian norm of this vector.\n\n[https://en.wikipedia.org/wiki/Euclidean_distance](https://en.wikipedia.org/wiki/Euclidean_distance)","summary":"

Returns the magnitude/euclidian norm of this vector.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L419","def":{"name":"magnitude","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"sum = reduce(0.0) do |acc, e|\n acc = acc + (e * e)\nend\nMath.sqrt(sum)\n"}},{"id":"map(&block)-instance-method","html_id":"map(&block)-instance-method","name":"map","doc":"Invokes the given block for each element of `self`.","summary":"

Invokes the given block for each element of self.

","abstract":false,"args":[],"args_string":"(&block)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L379","def":{"name":"map","args":[],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.new(size) do |i|\n yield @buffer[i]\nend"}},{"id":"map!(&block)-instance-method","html_id":"map!(&block)-instance-method","name":"map!","doc":"Invokes the given block for each element of `self`, replacing the element\nwith the value returned by the block. Returns `self`.\n\n```\nvec = Vector{1.0, 2.0, 3.0}\nvec.map! { |x| x * x }\na # => Vector{1.0, 4.0, 9.0}\n```","summary":"

Invokes the given block for each element of self, replacing the element with the value returned by the block.

","abstract":false,"args":[],"args_string":"(&block)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L400","def":{"name":"map!","args":[],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"@buffer.map!(size) do |e|\n yield e\nend\nself\n"}},{"id":"map_with_index(&block)-instance-method","html_id":"map_with_index(&block)-instance-method","name":"map_with_index","doc":"Optimized version of `Enumerable#map_with_index`.","summary":"

Optimized version of Enumerable#map_with_index.

","abstract":false,"args":[],"args_string":"(&block)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L406","def":{"name":"map_with_index","args":[],"double_splat":null,"splat_index":null,"yields":2,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.new(size) do |i|\n yield @buffer[i], i\nend"}},{"id":"map_with_index!(&block)-instance-method","html_id":"map_with_index!(&block)-instance-method","name":"map_with_index!","doc":"Like `map_with_index`, but mutates `self` instead of allocating a new object.","summary":"

Like #map_with_index, but mutates self instead of allocating a new object.

","abstract":false,"args":[],"args_string":"(&block)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L411","def":{"name":"map_with_index!","args":[],"double_splat":null,"splat_index":null,"yields":2,"block_arg":null,"return_type":"","visibility":"Public","body":"to_unsafe.map_with_index!(size) do |e, i|\n yield e, i\nend\nself\n"}},{"id":"max-instance-method","html_id":"max-instance-method","name":"max","doc":"Returns the (absolute) largest element in this vector.","summary":"

Returns the (absolute) largest element in this vector.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L589","def":{"name":"max","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"reduce do |acc, i|\n i.abs > acc.abs ? i : acc\nend"}},{"id":"max_index-instance-method","html_id":"max_index-instance-method","name":"max_index","doc":"Gets the index of the largest element in this vector.","summary":"

Gets the index of the largest element in this vector.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L594","def":{"name":"max_index","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"idx = 0\neach_with_index do |e, i|\n idx = e.abs > self[idx].abs ? i : idx\nend\nidx\n"}},{"id":"multiply(value)-instance-method","html_id":"multiply(value)-instance-method","name":"multiply","doc":"When the input is a number, this returns the result of multiplying\nit to all vector elements. When it's a vector, the vectors\nwill be element-wise multiplied.","summary":"

When the input is a number, this returns the result of multiplying it to all vector elements.

","abstract":false,"args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(value)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L502","def":{"name":"multiply","args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"run_binary_op(value) do |a, b|\n a * b\nend"}},{"id":"parallel_to?(vector)-instance-method","html_id":"parallel_to?(vector)-instance-method","name":"parallel_to?","doc":"Returns whether the vectors are parallel to each other.","summary":"

Returns whether the vectors are parallel to each other.

","abstract":false,"args":[{"name":"vector","doc":null,"default_value":"","external_name":"vector","restriction":""}],"args_string":"(vector)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L469","def":{"name":"parallel_to?","args":[{"name":"vector","doc":null,"default_value":"","external_name":"vector","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"angle = angle_from(vector)\nangle <= Apatite.precision\n"}},{"id":"perpendicular_to?(vector)-instance-method","html_id":"perpendicular_to?(vector)-instance-method","name":"perpendicular_to?","doc":"Returns whether the vectors are perpendicular to each other.","summary":"

Returns whether the vectors are perpendicular to each other.

","abstract":false,"args":[{"name":"vector","doc":null,"default_value":"","external_name":"vector","restriction":""}],"args_string":"(vector)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L481","def":{"name":"perpendicular_to?","args":[{"name":"vector","doc":null,"default_value":"","external_name":"vector","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"(dot(vector)).abs <= Apatite.precision"}},{"id":"pretty_print(pp):Nil-instance-method","html_id":"pretty_print(pp):Nil-instance-method","name":"pretty_print","doc":null,"summary":null,"abstract":false,"args":[{"name":"pp","doc":null,"default_value":"","external_name":"pp","restriction":""}],"args_string":"(pp) : Nil","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L754","def":{"name":"pretty_print","args":[{"name":"pp","doc":null,"default_value":"","external_name":"pp","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Nil","visibility":"Public","body":"pp.list(\"Vector{\", self, \"}\")"}},{"id":"product-instance-method","html_id":"product-instance-method","name":"product","doc":"Get the product of all elements in this vector.","summary":"

Get the product of all elements in this vector.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L567","def":{"name":"product","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"reduce do |acc, v|\n acc = acc * v\nend"}},{"id":"push(*values:Float64)-instance-method","html_id":"push(*values:Float64)-instance-method","name":"push","doc":null,"summary":null,"abstract":false,"args":[{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":"Float64"}],"args_string":"(*values : Float64)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L665","def":{"name":"push","args":[{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":"Float64"}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"new_size = @size + values.size\nif new_size > @capacity\n resize_to_capacity(Math.pw2ceil(new_size))\nend\nvalues.each_with_index do |value, i|\n @buffer[@size + i] = value\nend\n@size = new_size\nself\n"}},{"id":"push(value:Float64)-instance-method","html_id":"push(value:Float64)-instance-method","name":"push","doc":null,"summary":null,"abstract":false,"args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":"Float64"}],"args_string":"(value : Float64)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L658","def":{"name":"push","args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":"Float64"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"check_needs_resize\n@buffer[@size] = value\n@size = @size + 1\nself\n"}},{"id":"reflection_in(object)-instance-method","html_id":"reflection_in(object)-instance-method","name":"reflection_in","doc":"Returns the result of reflecting the point in the given `object`\n(point, line, or plane).","summary":"

Returns the result of reflecting the point in the given object (point, line, or plane).

","abstract":false,"args":[{"name":"object","doc":null,"default_value":"","external_name":"object","restriction":""}],"args_string":"(object)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L684","def":{"name":"reflection_in","args":[{"name":"object","doc":null,"default_value":"","external_name":"object","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if object.is_a?(Plane) || object.is_a?(Line)\n p = @elements.dup\n c = (object.point_closest_to(p)).elements\n return Vector.create([C[0] + (C[0] - P[0]), C[1] + (C[1] - P[1]), C[2] + (C[2] - (P[2] || 0))])\nend\nq = object.is_a?(Vector) ? object.elements : object\nif @elements.size == q.size\nelse\n return nil\nend\nmap_with_index do |x, i|\n q[i - 1] + (q[i - 1] - x)\nend\n"}},{"id":"rotate(t,object)-instance-method","html_id":"rotate(t,object)-instance-method","name":"rotate","doc":"Rotates the vector about the given `object`. The object should\nbe a point if the vector is 2D, and a line if it is 3D. Be\ncareful with line directions!","summary":"

Rotates the vector about the given object.

","abstract":false,"args":[{"name":"t","doc":null,"default_value":"","external_name":"t","restriction":""},{"name":"object","doc":null,"default_value":"","external_name":"object","restriction":""}],"args_string":"(t, object)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L678","def":{"name":"rotate","args":[{"name":"t","doc":null,"default_value":"","external_name":"t","restriction":""},{"name":"object","doc":null,"default_value":"","external_name":"object","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":""}},{"id":"round-instance-method","html_id":"round-instance-method","name":"round","doc":"Gets the result of rounding the elements of the vector.","summary":"

Gets the result of rounding the elements of the vector.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L612","def":{"name":"round","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"map do |x|\n x.round\nend"}},{"id":"set_elements(elements)-instance-method","html_id":"set_elements(elements)-instance-method","name":"set_elements","doc":null,"summary":null,"abstract":false,"args":[{"name":"elements","doc":null,"default_value":"","external_name":"elements","restriction":""}],"args_string":"(elements)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L726","def":{"name":"set_elements","args":[{"name":"elements","doc":null,"default_value":"","external_name":"elements","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@elements = elements.is_a?(Vector) ? elements.elements : elements\nself\n"}},{"id":"sigmoid-instance-method","html_id":"sigmoid-instance-method","name":"sigmoid","doc":"Sums the numbers in the vector and returns a sigmoid value\nacross the whole vector.","summary":"

Sums the numbers in the vector and returns a sigmoid value across the whole vector.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L707","def":{"name":"sigmoid","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"LinearAlgebra.sigmoid(sum)"}},{"id":"size:Int32-instance-method","html_id":"size:Int32-instance-method","name":"size","doc":"Returns the number of elements in the vector","summary":"

Returns the number of elements in the vector

","abstract":false,"args":[],"args_string":" : Int32","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L24","def":{"name":"size","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Int32","visibility":"Public","body":"@size"}},{"id":"snap_to(value)-instance-method","html_id":"snap_to(value)-instance-method","name":"snap_to","doc":"Returns a copy of the vector with elements set to `value` if\nthey differ from it by less than `Apetite.precision`","summary":"

Returns a copy of the vector with elements set to value if they differ from it by less than Apetite.precision

","abstract":false,"args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(value)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L623","def":{"name":"snap_to","args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"map do |y|\n (y - x).abs <= Apetite.precision ? value : y\nend"}},{"id":"subtract(value)-instance-method","html_id":"subtract(value)-instance-method","name":"subtract","doc":"When the input is a number, this returns the result of subtracting\nit to all vector elements. When it's a vector, the vectors\nwill be subtracted.","summary":"

When the input is a number, this returns the result of subtracting it to all vector elements.

","abstract":false,"args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(value)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L495","def":{"name":"subtract","args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"run_binary_op(value) do |a, b|\n a - b\nend"}},{"id":"sum-instance-method","html_id":"sum-instance-method","name":"sum","doc":"Returns the sum of all elements in the vector.","summary":"

Returns the sum of all elements in the vector.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L507","def":{"name":"sum","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"reduce(0) do |acc, i|\n acc + i\nend"}},{"id":"to_3d-instance-method","html_id":"to_3d-instance-method","name":"to_3d","doc":"Utility to make sure vectors are 3D. If they are 2D, a zero\nz-component is added.","summary":"

Utility to make sure vectors are 3D.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L713","def":{"name":"to_3d","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"v = dup\ncase v.elements.size\nwhen 3\n break\nwhen 2\n v.elements.push(0)\nelse\n return nil\nend\nreturn v\n"}},{"id":"to_a-instance-method","html_id":"to_a-instance-method","name":"to_a","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L744","def":{"name":"to_a","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Array(Float64).new(size) do |i|\n self[i]\nend"}},{"id":"to_diagonal_matrix-instance-method","html_id":"to_diagonal_matrix-instance-method","name":"to_diagonal_matrix","doc":"Returns a diagonal `Matrix` with the vectors elements as its\ndiagonal elements.","summary":"

Returns a diagonal Matrix with the vectors elements as its diagonal elements.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L607","def":{"name":"to_diagonal_matrix","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix::Diagonal.new(elements)"}},{"id":"to_s(io)-instance-method","html_id":"to_s(io)-instance-method","name":"to_s","doc":null,"summary":null,"abstract":false,"args":[{"name":"io","doc":null,"default_value":"","external_name":"io","restriction":""}],"args_string":"(io)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L748","def":{"name":"to_s","args":[{"name":"io","doc":null,"default_value":"","external_name":"io","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"io << \"{\"\njoin(\", \", io, &.inspect(io))\nio << \"}\"\n"}},{"id":"to_unit_vector-instance-method","html_id":"to_unit_vector-instance-method","name":"to_unit_vector","doc":"Returns a new vector created by normalizing this one\nto have a magnitude of `1`. If the vector is a zero\nvector, it will not be modified.","summary":"

Returns a new vector created by normalizing this one to have a magnitude of 1.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L433","def":{"name":"to_unit_vector","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"r = magnitude\nr == 0 ? dup : map do |x|\n x.to_f64 / r\nend\n"}},{"id":"to_unsafe:Pointer(Float64)-instance-method","html_id":"to_unsafe:Pointer(Float64)-instance-method","name":"to_unsafe","doc":"Returns a pointer to the internal buffer where `self`'s elements are stored.\n\nThis method is **unsafe** because it returns a pointer, and the pointed might eventually\nnot be that of `self` if the array grows and its internal buffer is reallocated.\n\n```\nvec = Vector{1.0, 2.0, 3.0}\nvec.to_unsafe[0] # => 1.0\n```","summary":"

Returns a pointer to the internal buffer where self's elements are stored.

","abstract":false,"args":[],"args_string":" : Pointer(Float64)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L772","def":{"name":"to_unsafe","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Pointer(Float64)","visibility":"Public","body":"@buffer"}},{"id":"top(n)-instance-method","html_id":"top(n)-instance-method","name":"top","doc":"Returns a vector containing only the first `n` elements.","summary":"

Returns a vector containing only the first n elements.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L548","def":{"name":"top","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"elements = [] of Float64\neach_with_index do |e, i|\n if i < n\n elements << e\n end\nend\nVector.create(elements)\n"}},{"id":"transpose-instance-method","html_id":"transpose-instance-method","name":"transpose","doc":"Transpose this vector into a 1xn `Matrix`","summary":"

Transpose this vector into a 1xn Matrix

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L617","def":{"name":"transpose","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.col_vector(self)"}},{"id":"unsafe_fetch(index:Int)-instance-method","html_id":"unsafe_fetch(index:Int)-instance-method","name":"unsafe_fetch","doc":null,"summary":null,"abstract":false,"args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"}],"args_string":"(index : Int)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L759","def":{"name":"unsafe_fetch","args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@buffer[index]"}},{"id":"zero?-instance-method","html_id":"zero?-instance-method","name":"zero?","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L788","def":{"name":"zero?","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"all?(&.zero?)"}}],"macros":[],"types":[]}]}]},{"html_id":"github.com/watzon/apatite/Array","path":"Array.html","kind":"class","full_name":"Array(T)","name":"Array","abstract":false,"superclass":{"html_id":"github.com/watzon/apatite/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"github.com/watzon/apatite/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"github.com/watzon/apatite/Indexable","kind":"module","full_name":"Indexable","name":"Indexable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Iterable","kind":"module","full_name":"Iterable","name":"Iterable"},{"html_id":"github.com/watzon/apatite/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"github.com/watzon/apatite/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"apatite/core_ext/array.cr","line_number":1,"url":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/core_ext/array.cr"}],"repository_name":"github.com/watzon/apatite","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[{"html_id":"github.com/watzon/apatite/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"github.com/watzon/apatite/Indexable","kind":"module","full_name":"Indexable","name":"Indexable"}],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":null,"doc":"An `Array` is an ordered, integer-indexed collection of objects of type T.\n\nArray indexing starts at 0. A negative index is assumed to be\nrelative to the end of the array: -1 indicates the last element,\n-2 is the next to last element, and so on.\n\nAn `Array` can be created using the usual `new` method (several are provided), or with an array literal:\n\n```\nArray(Int32).new # => []\n[1, 2, 3] # Array(Int32)\n[1, \"hello\", 'x'] # Array(Int32 | String | Char)\n```\n\nAn `Array` can have mixed types, meaning T will be a union of types, but these are determined\nwhen the array is created, either by specifying T or by using an array literal. In the latter\ncase, T will be set to the union of the array literal elements' types.\n\nWhen creating an empty array you must always specify T:\n\n```\n[] of Int32 # same as Array(Int32)\n[] # syntax error\n```\n\nAn `Array` is implemented using an internal buffer of some capacity\nand is reallocated when elements are pushed to it when more capacity\nis needed. This is normally known as a [dynamic array](http://en.wikipedia.org/wiki/Dynamic_array).\n\nYou can use a special array literal syntax with other types too, as long as they define an argless\n`new` method and a `<<` method. `Set` is one such type:\n\n```\nset = Set{1, 2, 3} # => Set{1, 2, 3}\nset.class # => Set(Int32)\n```\n\nThe above is the same as this:\n\n```\nset = Set(typeof(1, 2, 3)).new\nset << 1\nset << 2\nset << 3\n```","summary":"

An Array is an ordered, integer-indexed collection of objects of type T.

","class_methods":[],"constructors":[],"instance_methods":[{"id":"all?-instance-method","html_id":"all?-instance-method","name":"all?","doc":"Tests whether all elements evaluate to true","summary":"

Tests whether all elements evaluate to true

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/core_ext/array.cr#L3","def":{"name":"all?","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"each do |i|\n if (!(!i)) == false\n return false\n end\nend\ntrue\n"}},{"id":"any?-instance-method","html_id":"any?-instance-method","name":"any?","doc":"Tests whether any of the elements evaluate to true","summary":"

Tests whether any of the elements evaluate to true

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/core_ext/array.cr#L11","def":{"name":"any?","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"each do |i|\n if (!(!i)) == true\n return true\n end\nend\nfalse\n"}},{"id":"shape-instance-method","html_id":"shape-instance-method","name":"shape","doc":"Get the array's dimensions","summary":"

Get the array's dimensions

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/core_ext/array.cr#L19","def":{"name":"shape","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"max = max_by do |i|\n i.is_a?(Array) ? i.size : i\nend\nmax.is_a?(Array) ? [size, max.size] : [max]\n"}},{"id":"to_vec-instance-method","html_id":"to_vec-instance-method","name":"to_vec","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/core_ext/array.cr#L24","def":{"name":"to_vec","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Apatite::Vector.create(self)"}}],"macros":[],"types":[]}]}} \ No newline at end of file diff --git a/docs/search-index.js b/docs/search-index.js index ddf95ed..67791fc 100644 --- a/docs/search-index.js +++ b/docs/search-index.js @@ -1 +1 @@ -crystal_doc_search_index_callback({"repository_name":"github.com/watzon/apatite","body":"# Apatite\n\nApatite is meant to be a collecion of mathmatical and scientific computing algorithms for the Crystal programming language. I don't expect it to ever reach the level of completeness as numpy, but hopefully it can save some people the trouble of implementing these methods on their own.\n\n## Installation\n\n1. Add the dependency to your `shard.yml`:\n\n ```yaml\n dependencies:\n apatite:\n github: watzon/apatite\n ```\n\n2. Run `shards install`\n\n## Usage\n\n```crystal\nrequire \"apatite\"\n```\n\nTODO: Write usage instructions here, but first write the library...\n\n## Roadmap\n\n- [ ] Apetite\n\t- [ ] Vector Math\n\t\t- [ ] Matrix\n\t\t- [ ] NDArray\n\t\t- [x] Vector\n\t\t- [ ] Line\n\t\t- [ ] Plane\n\t\t- [ ] Polygon\n\t\t- [ ] LinkedList\n\t\n\n\n## Contributing\n\n1. Fork it ()\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n## Contributors\n\n- [Chris Watson](https://github.com/watzon) - creator and maintainer","program":{"html_id":"github.com/watzon/apatite/toplevel","path":"toplevel.html","kind":"module","full_name":"Top Level Namespace","name":"Top Level Namespace","abstract":false,"superclass":null,"ancestors":[],"locations":[],"repository_name":"github.com/watzon/apatite","program":true,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":null,"doc":null,"summary":null,"class_methods":[],"constructors":[],"instance_methods":[],"macros":[],"types":[{"html_id":"github.com/watzon/apatite/Apatite","path":"Apatite.html","kind":"module","full_name":"Apatite","name":"Apatite","abstract":false,"superclass":null,"ancestors":[{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra","kind":"module","full_name":"Apatite::LinearAlgebra","name":"LinearAlgebra"}],"locations":[{"filename":"apatite/linear_algebra/ndarray.cr","line_number":1,"url":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/ndarray.cr"},{"filename":"apatite/linear_algebra.cr","line_number":5,"url":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra.cr"},{"filename":"apatite.cr","line_number":10,"url":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite.cr"},{"filename":"apatite/version.cr","line_number":1,"url":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/version.cr"}],"repository_name":"github.com/watzon/apatite","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[{"id":"I","name":"I","value":"Vector::I","doc":"Cartesian unit vector I\n\n`Vector{1.0, 0.0, 0.0}`","summary":"

Cartesian unit vector I

"},{"id":"J","name":"J","value":"Vector::J","doc":"Cartesian unit vector J\n\n`Vector{0.0, 1.0, 0.0}`","summary":"

Cartesian unit vector J

"},{"id":"K","name":"K","value":"Vector::K","doc":"Cartesian unit vector K\n\n`Vector{0.0, 0.0, 1.0}`","summary":"

Cartesian unit vector K

"},{"id":"VERSION","name":"VERSION","value":"\"0.1.0\"","doc":null,"summary":null}],"included_modules":[{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra","kind":"module","full_name":"Apatite::LinearAlgebra","name":"LinearAlgebra"}],"extended_modules":[{"html_id":"github.com/watzon/apatite/Apatite","kind":"module","full_name":"Apatite","name":"Apatite"}],"subclasses":[],"including_types":[],"namespace":null,"doc":"Apatite is a fundimental package for scientific computing in Crystal. If that\nsounds like a modified version of the first line from the NumPy homepage,\nthat's because it is. Apatite has (ok, will have) all of the goodness\nof NumPy sitting atop the blazing speed and beautiful syntax\nof Crystal.","summary":"

Apatite is a fundimental package for scientific computing in Crystal.

","class_methods":[],"constructors":[],"instance_methods":[{"id":"as_vector(input:Indexable)-instance-method","html_id":"as_vector(input:Indexable)-instance-method","name":"as_vector","doc":"Creates a new vector from the given `input`. Input can be any\n`Indexable` type.","summary":"

Creates a new vector from the given input.

","abstract":false,"args":[{"name":"input","doc":null,"default_value":"","external_name":"input","restriction":"Indexable"}],"args_string":"(input : Indexable)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite.cr#L61","def":{"name":"as_vector","args":[{"name":"input","doc":null,"default_value":"","external_name":"input","restriction":"Indexable"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.create(input)"}},{"id":"basis(size,index)-instance-method","html_id":"basis(size,index)-instance-method","name":"basis","doc":"Creates a standard basis-n vector of the given `size` and `index`.","summary":"

Creates a standard basis-n vector of the given size and index.

","abstract":false,"args":[{"name":"size","doc":null,"default_value":"","external_name":"size","restriction":""},{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":""}],"args_string":"(size, index)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite.cr#L66","def":{"name":"basis","args":[{"name":"size","doc":null,"default_value":"","external_name":"size","restriction":""},{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.basis(size, index)"}},{"id":"diagonal(values)-instance-method","html_id":"diagonal(values)-instance-method","name":"diagonal","doc":"Creates a matrix where the diagonal elements are composed of `values`.","summary":"

Creates a matrix where the diagonal elements are composed of values.

","abstract":false,"args":[{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":""}],"args_string":"(values)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite.cr#L89","def":{"name":"diagonal","args":[{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.diagonal(values)"}},{"id":"empty-instance-method","html_id":"empty-instance-method","name":"empty","doc":"Returns a new empty `Vector`","summary":"

Returns a new empty Vector

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite.cr#L34","def":{"name":"empty","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.new"}},{"id":"empty_matrix(row_count=0,column_count=0)-instance-method","html_id":"empty_matrix(row_count=0,column_count=0)-instance-method","name":"empty_matrix","doc":"Creates a new empty matrix with the given `row_count` and\n`column_count`. At lease one of `row_count` or\n`column_count` must be zero.","summary":"

Creates a new empty matrix with the given row_count and column_count.

","abstract":false,"args":[{"name":"row_count","doc":null,"default_value":"0","external_name":"row_count","restriction":""},{"name":"column_count","doc":null,"default_value":"0","external_name":"column_count","restriction":""}],"args_string":"(row_count = 0, column_count = 0)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite.cr#L84","def":{"name":"empty_matrix","args":[{"name":"row_count","doc":null,"default_value":"0","external_name":"row_count","restriction":""},{"name":"column_count","doc":null,"default_value":"0","external_name":"column_count","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.new(rows, column_count)"}},{"id":"eye(n)-instance-method","html_id":"eye(n)-instance-method","name":"eye","doc":"Creates a new diagonal matrix of size `n` with ones in the diagonal\nand zeros elsewhere.","summary":"

Creates a new diagonal matrix of size n with ones in the diagonal and zeros elsewhere.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite.cr#L95","def":{"name":"eye","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.eye(n)"}},{"id":"full(n,i)-instance-method","html_id":"full(n,i)-instance-method","name":"full","doc":"Returns a new vector of size `n` filled with `i`","summary":"

Returns a new vector of size n filled with i

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""},{"name":"i","doc":null,"default_value":"","external_name":"i","restriction":""}],"args_string":"(n, i)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite.cr#L49","def":{"name":"full","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""},{"name":"i","doc":null,"default_value":"","external_name":"i","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.new(n, i)"}},{"id":"identity(n)-instance-method","html_id":"identity(n)-instance-method","name":"identity","doc":"Creates a `n x n` identity matrix.","summary":"

Creates a n x n identity matrix.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite.cr#L100","def":{"name":"identity","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.identity(n)"}},{"id":"ones(n)-instance-method","html_id":"ones(n)-instance-method","name":"ones","doc":"Returns a new vector filled with `n` ones.","summary":"

Returns a new vector filled with n ones.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite.cr#L39","def":{"name":"ones","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.ones(n)"}},{"id":"random(n,range=nil)-instance-method","html_id":"random(n,range=nil)-instance-method","name":"random","doc":"Creates a new vector of size `n` filled with random numbers. A `range`\ncan optionally be passed in if you want to limit the random numbers\nto a given range.","summary":"

Creates a new vector of size n filled with random numbers.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""},{"name":"range","doc":null,"default_value":"nil","external_name":"range","restriction":""}],"args_string":"(n, range = nil)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite.cr#L73","def":{"name":"random","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""},{"name":"range","doc":null,"default_value":"nil","external_name":"range","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.random(n, range)"}},{"id":"row_vector(row)-instance-method","html_id":"row_vector(row)-instance-method","name":"row_vector","doc":"Creates a single-row matrix where the values of that row are as given in `row`.","summary":"

Creates a single-row matrix where the values of that row are as given in row.

","abstract":false,"args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":""}],"args_string":"(row)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite.cr#L105","def":{"name":"row_vector","args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.row_vector(row)"}},{"id":"scalar(n,value)-instance-method","html_id":"scalar(n,value)-instance-method","name":"scalar","doc":"Creates an `n` by `n` diagonal matrix where each diagonal element is value.","summary":"

Creates an n by n diagonal matrix where each diagonal element is value.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(n, value)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite.cr#L110","def":{"name":"scalar","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.scalar(n, value)"}},{"id":"vector(n,&block)-instance-method","html_id":"vector(n,&block)-instance-method","name":"vector","doc":"Creates a new vector of size `n`, and invokes the block once\nfor each index of `self`, assigning the block's value in that index.","summary":"

Creates a new vector of size n, and invokes the block once for each index of self, assigning the block's value in that index.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n, &block)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite.cr#L55","def":{"name":"vector","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.new(n) do |i|\n yield i\nend"}},{"id":"zeros(n)-instance-method","html_id":"zeros(n)-instance-method","name":"zeros","doc":"Returns a new vector filled with `n` zeros.","summary":"

Returns a new vector filled with n zeros.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite.cr#L44","def":{"name":"zeros","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.zeros(n)"}}],"macros":[],"types":[{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra","path":"Apatite/LinearAlgebra.html","kind":"module","full_name":"Apatite::LinearAlgebra","name":"LinearAlgebra","abstract":false,"superclass":null,"ancestors":[],"locations":[{"filename":"apatite/linear_algebra/ndarray.cr","line_number":1,"url":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/ndarray.cr"},{"filename":"apatite/linear_algebra/vector.cr","line_number":1,"url":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr"},{"filename":"apatite/linear_algebra/matrix.cr","line_number":3,"url":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr"},{"filename":"apatite/linear_algebra.cr","line_number":6,"url":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra.cr"}],"repository_name":"github.com/watzon/apatite","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[],"extended_modules":[{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra","kind":"module","full_name":"Apatite::LinearAlgebra","name":"LinearAlgebra"}],"subclasses":[],"including_types":[{"html_id":"github.com/watzon/apatite/Apatite","kind":"module","full_name":"Apatite","name":"Apatite"}],"namespace":{"html_id":"github.com/watzon/apatite/Apatite","kind":"module","full_name":"Apatite","name":"Apatite"},"doc":null,"summary":null,"class_methods":[],"constructors":[],"instance_methods":[{"id":"sigmoid(input:Number)-instance-method","html_id":"sigmoid(input:Number)-instance-method","name":"sigmoid","doc":"Calculates the sigmoid curve for a numeric input.\n\n`f(x) = 1/(1 + e^-x)`\n\nSee also: [Sigmoid function (WikiWand)](https://www.wikiwand.com/en/Sigmoid_function)","summary":"

Calculates the sigmoid curve for a numeric input.

","abstract":false,"args":[{"name":"input","doc":null,"default_value":"","external_name":"input","restriction":"Number"}],"args_string":"(input : Number)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra.cr#L14","def":{"name":"sigmoid","args":[{"name":"input","doc":null,"default_value":"","external_name":"input","restriction":"Number"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"num = input.to_f64\n1 / (1 + (Math.exp(-num)))\n"}},{"id":"sigmoid_d(input:Number)-instance-method","html_id":"sigmoid_d(input:Number)-instance-method","name":"sigmoid_d","doc":"Calculates the derivative sigmoid curve for a numeric input.\n\n`f'(x) = f(x)(1 - f(x)),`","summary":"

Calculates the derivative sigmoid curve for a numeric input.

","abstract":false,"args":[{"name":"input","doc":null,"default_value":"","external_name":"input","restriction":"Number"}],"args_string":"(input : Number)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra.cr#L22","def":{"name":"sigmoid_d","args":[{"name":"input","doc":null,"default_value":"","external_name":"input","restriction":"Number"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"num = input.to_f64\nnum * (1 - num)\n"}}],"macros":[],"types":[{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra/Matrix","path":"Apatite/LinearAlgebra/Matrix.html","kind":"class","full_name":"Apatite::LinearAlgebra::Matrix","name":"Matrix","abstract":false,"superclass":{"html_id":"github.com/watzon/apatite/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"github.com/watzon/apatite/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"github.com/watzon/apatite/Indexable","kind":"module","full_name":"Indexable","name":"Indexable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Iterable","kind":"module","full_name":"Iterable","name":"Iterable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"github.com/watzon/apatite/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"apatite/linear_algebra/matrix.cr","line_number":4,"url":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr"}],"repository_name":"github.com/watzon/apatite","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[{"html_id":"github.com/watzon/apatite/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Indexable","kind":"module","full_name":"Indexable","name":"Indexable"}],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra","kind":"module","full_name":"Apatite::LinearAlgebra","name":"LinearAlgebra"},"doc":null,"summary":null,"class_methods":[{"id":"[](*rows)-class-method","html_id":"[](*rows)-class-method","name":"[]","doc":"Creates a matrix where each argument is a row.","summary":"

Creates a matrix where each argument is a row.

","abstract":false,"args":[{"name":"rows","doc":null,"default_value":"","external_name":"rows","restriction":""}],"args_string":"(*rows)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L22","def":{"name":"[]","args":[{"name":"rows","doc":null,"default_value":"","external_name":"rows","restriction":""}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"rows(rows)"}},{"id":"build(row_count,column_count=row_count,&block)-class-method","html_id":"build(row_count,column_count=row_count,&block)-class-method","name":"build","doc":"Creates a matrix of size `row_count x column_count`. It fills the values by calling\nthe given block, passing the current row and column.","summary":"

Creates a matrix of size row_count x column_count.

","abstract":false,"args":[{"name":"row_count","doc":null,"default_value":"","external_name":"row_count","restriction":""},{"name":"column_count","doc":null,"default_value":"row_count","external_name":"column_count","restriction":""}],"args_string":"(row_count, column_count = row_count, &block)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L28","def":{"name":"build","args":[{"name":"row_count","doc":null,"default_value":"","external_name":"row_count","restriction":""},{"name":"column_count","doc":null,"default_value":"row_count","external_name":"column_count","restriction":""}],"double_splat":null,"splat_index":null,"yields":2,"block_arg":null,"return_type":"","visibility":"Public","body":"if row_count < 0 || column_count < 0\n raise(ArgumentError.new)\nend\nrows = Array.new(row_count) do |i|\n Vector.new(column_count) do |j|\n yield i, j\n end\nend\nMatrix.new(rows, column_count)\n"}},{"id":"col_vector(column)-class-method","html_id":"col_vector(column)-class-method","name":"col_vector","doc":"Creates a single-column matrix where the values of that column are as given in column.","summary":"

Creates a single-column matrix where the values of that column are as given in column.

","abstract":false,"args":[{"name":"column","doc":null,"default_value":"","external_name":"column","restriction":""}],"args_string":"(column)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L39","def":{"name":"col_vector","args":[{"name":"column","doc":null,"default_value":"","external_name":"column","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.new([column].transpose, 1)"}},{"id":"columns(columns)-class-method","html_id":"columns(columns)-class-method","name":"columns","doc":"Creates a matrix using `columns` as an array of column vectors.","summary":"

Creates a matrix using .columns as an array of column vectors.

","abstract":false,"args":[{"name":"columns","doc":null,"default_value":"","external_name":"columns","restriction":""}],"args_string":"(columns)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L44","def":{"name":"columns","args":[{"name":"columns","doc":null,"default_value":"","external_name":"columns","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"(rows(columns)).transpose"}},{"id":"diagonal(values)-class-method","html_id":"diagonal(values)-class-method","name":"diagonal","doc":"Creates a matrix where the diagonal elements are composed of `values`.","summary":"

Creates a matrix where the diagonal elements are composed of values.

","abstract":false,"args":[{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":""}],"args_string":"(values)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L70","def":{"name":"diagonal","args":[{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"size = values.size\nif size == 0\n return Matrix.empty\nend\nrows = Array.new(size) do |j|\n row = Array.new(size, 0)\n row[j] = values[j]\n row\nend\nnew(rows)\n"}},{"id":"diagonal(*values)-class-method","html_id":"diagonal(*values)-class-method","name":"diagonal","doc":"Creates a matrix where the diagonal elements are composed of `values`.","summary":"

Creates a matrix where the diagonal elements are composed of values.

","abstract":false,"args":[{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":""}],"args_string":"(*values)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L84","def":{"name":"diagonal","args":[{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":""}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.diagonal(values)"}},{"id":"empty(row_count=0,column_count=0)-class-method","html_id":"empty(row_count=0,column_count=0)-class-method","name":"empty","doc":"Creates a empty matrix of `row_count x column_count`. At least one of\n`row_count` or `column_count` must be 0.","summary":"

Creates a empty matrix of row_count x column_count.

","abstract":false,"args":[{"name":"row_count","doc":null,"default_value":"0","external_name":"row_count","restriction":""},{"name":"column_count","doc":null,"default_value":"0","external_name":"column_count","restriction":""}],"args_string":"(row_count = 0, column_count = 0)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L90","def":{"name":"empty","args":[{"name":"row_count","doc":null,"default_value":"0","external_name":"row_count","restriction":""},{"name":"column_count","doc":null,"default_value":"0","external_name":"column_count","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if (column_count != 0) && (row_count != 0)\n raise(ArgumentError.new(\"One size must be 0\"))\nend\nif column_count < 0 || row_count < 0\n raise(ArgumentError.new(\"Negative size\"))\nend\nMatrix.new(([] of Vector) * row_count, column_count)\n"}},{"id":"eye(n)-class-method","html_id":"eye(n)-class-method","name":"eye","doc":"Creates a new diagonal matrix of size `n` with ones in the diagonal\nand zeros elsewhere.","summary":"

Creates a new diagonal matrix of size n with ones in the diagonal and zeros elsewhere.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L98","def":{"name":"eye","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.diagonal([1] * n)"}},{"id":"hstack(x,*matrices)-class-method","html_id":"hstack(x,*matrices)-class-method","name":"hstack","doc":"TODO","summary":"

TODO

","abstract":false,"args":[{"name":"x","doc":null,"default_value":"","external_name":"x","restriction":""},{"name":"matrices","doc":null,"default_value":"","external_name":"matrices","restriction":""}],"args_string":"(x, *matrices)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L103","def":{"name":"hstack","args":[{"name":"x","doc":null,"default_value":"","external_name":"x","restriction":""},{"name":"matrices","doc":null,"default_value":"","external_name":"matrices","restriction":""}],"double_splat":null,"splat_index":1,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":""}},{"id":"identity(n)-class-method","html_id":"identity(n)-class-method","name":"identity","doc":"Creates a `n x n` identity matrix.","summary":"

Creates a n x n identity matrix.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L107","def":{"name":"identity","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"scalar(n, 1)"}},{"id":"row_vector(row)-class-method","html_id":"row_vector(row)-class-method","name":"row_vector","doc":"Creates a single-row matrix where the values of that row are as given in `row`.","summary":"

Creates a single-row matrix where the values of that row are as given in #row.

","abstract":false,"args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":""}],"args_string":"(row)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L112","def":{"name":"row_vector","args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.new([row], 0)"}},{"id":"rows(rows)-class-method","html_id":"rows(rows)-class-method","name":"rows","doc":"Creates a matrix where rows is an array of arrays, each of which is a row of the matrix.","summary":"

Creates a matrix where rows is an array of arrays, each of which is a row of the matrix.

","abstract":false,"args":[{"name":"rows","doc":null,"default_value":"","external_name":"rows","restriction":""}],"args_string":"(rows)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L117","def":{"name":"rows","args":[{"name":"rows","doc":null,"default_value":"","external_name":"rows","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"size = rows[0]? ? rows[0].size : 0\nrows.each do |row|\n if row.size == size\n else\n raise(\"Dimension mismatch: row size differs (#{row.size} should be #{size})\")\n end\nend\nMatrix.new(rows, size)\n"}},{"id":"scalar(n,value)-class-method","html_id":"scalar(n,value)-class-method","name":"scalar","doc":"Creates an `n` by `n` diagonal matrix where each diagonal element is value.","summary":"

Creates an n by n diagonal matrix where each diagonal element is value.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(n, value)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L126","def":{"name":"scalar","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.diagonal(Array.new(n, value))"}},{"id":"vstack(x,y)-class-method","html_id":"vstack(x,y)-class-method","name":"vstack","doc":"TODO","summary":"

TODO

","abstract":false,"args":[{"name":"x","doc":null,"default_value":"","external_name":"x","restriction":""},{"name":"y","doc":null,"default_value":"","external_name":"y","restriction":""}],"args_string":"(x, y)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L131","def":{"name":"vstack","args":[{"name":"x","doc":null,"default_value":"","external_name":"x","restriction":""},{"name":"y","doc":null,"default_value":"","external_name":"y","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":""}},{"id":"zero(row_count,column_count=row_count)-class-method","html_id":"zero(row_count,column_count=row_count)-class-method","name":"zero","doc":"Creates a zero matrix.","summary":"

Creates a zero matrix.

","abstract":false,"args":[{"name":"row_count","doc":null,"default_value":"","external_name":"row_count","restriction":""},{"name":"column_count","doc":null,"default_value":"row_count","external_name":"column_count","restriction":""}],"args_string":"(row_count, column_count = row_count)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L135","def":{"name":"zero","args":[{"name":"row_count","doc":null,"default_value":"","external_name":"row_count","restriction":""},{"name":"column_count","doc":null,"default_value":"row_count","external_name":"column_count","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"rows = Array.new(row_count) do\n Vector.new(column_count)\nend\nMatrix.new(rows, column_count)\n"}}],"constructors":[{"id":"new(rows,column_count:Int32?=nil)-class-method","html_id":"new(rows,column_count:Int32?=nil)-class-method","name":"new","doc":null,"summary":null,"abstract":false,"args":[{"name":"rows","doc":null,"default_value":"","external_name":"rows","restriction":""},{"name":"column_count","doc":null,"default_value":"nil","external_name":"column_count","restriction":"Int32 | ::Nil"}],"args_string":"(rows, column_count : Int32? = nil)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L15","def":{"name":"new","args":[{"name":"rows","doc":null,"default_value":"","external_name":"rows","restriction":""},{"name":"column_count","doc":null,"default_value":"nil","external_name":"column_count","restriction":"Int32 | ::Nil"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"_ = allocate\n_.initialize(rows, column_count)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"id":"*(other:Matrix)-instance-method","html_id":"*(other:Matrix)-instance-method","name":"*","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"args_string":"(other : Matrix)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L140","def":{"name":"*","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if column_count != other.column_count\n raise(\"Dimension mismatch\")\nend\nrows = Array.new(row_count) do |i|\n Vector.new(other.column_count) do |j|\n (0...column_count).reduce(0.0) do |vij, k|\n vij + (self[i, k] * other[k, j])\n end\n end\nend\nreturn Matrix.new(rows, other.column_count)\n"}},{"id":"*(int:Int)-instance-method","html_id":"*(int:Int)-instance-method","name":"*","doc":null,"summary":null,"abstract":false,"args":[{"name":"int","doc":null,"default_value":"","external_name":"int","restriction":"Int"}],"args_string":"(int : Int)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L154","def":{"name":"*","args":[{"name":"int","doc":null,"default_value":"","external_name":"int","restriction":"Int"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"rows = self.rows.map do |row|\n row.map do |e|\n e * int\n end\nend\nMatrix.new(rows, column_count)\n"}},{"id":"*(ind:Indexable)-instance-method","html_id":"*(ind:Indexable)-instance-method","name":"*","doc":null,"summary":null,"abstract":false,"args":[{"name":"ind","doc":null,"default_value":"","external_name":"ind","restriction":"Indexable"}],"args_string":"(ind : Indexable)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L161","def":{"name":"*","args":[{"name":"ind","doc":null,"default_value":"","external_name":"ind","restriction":"Indexable"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"m = column_vector\nr = self * m\nr.column(0)\n"}},{"id":"**(int)-instance-method","html_id":"**(int)-instance-method","name":"**","doc":null,"summary":null,"abstract":false,"args":[{"name":"int","doc":null,"default_value":"","external_name":"int","restriction":""}],"args_string":"(int)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L167","def":{"name":"**","args":[{"name":"int","doc":null,"default_value":"","external_name":"int","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if int >= 1\nelse\n raise(\"Number can not the less than 1\")\nend\nmat = self\n(int - 1).times do\n mat = mat * self\nend\nmat\n"}},{"id":"+(other:Matrix)-instance-method","html_id":"+(other:Matrix)-instance-method","name":"+","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"args_string":"(other : Matrix)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L176","def":{"name":"+","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if column_count != other.column_count\n raise(\"Dimension mismatch\")\nend\nrows = Array.new(row_count) do |i|\n Vector.new(other.column_count) do |j|\n self[i, j] + other[i, j]\n end\nend\nreturn Matrix.new(rows, other.column_count)\n"}},{"id":"+(vec:Indexable)-instance-method","html_id":"+(vec:Indexable)-instance-method","name":"+","doc":null,"summary":null,"abstract":false,"args":[{"name":"vec","doc":null,"default_value":"","external_name":"vec","restriction":"Indexable"}],"args_string":"(vec : Indexable)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L188","def":{"name":"+","args":[{"name":"vec","doc":null,"default_value":"","external_name":"vec","restriction":"Indexable"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"vec = vec.is_a?(Vector) ? vec : Vector.create(vec)\nself + (column_vector(vec))\n"}},{"id":"-(vec:Indexable)-instance-method","html_id":"-(vec:Indexable)-instance-method","name":"-","doc":null,"summary":null,"abstract":false,"args":[{"name":"vec","doc":null,"default_value":"","external_name":"vec","restriction":"Indexable"}],"args_string":"(vec : Indexable)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L205","def":{"name":"-","args":[{"name":"vec","doc":null,"default_value":"","external_name":"vec","restriction":"Indexable"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"vec = vec.is_a?(Vector) ? vec : Vector.create(vec)\nself + (column_vector(vec))\n"}},{"id":"-(other:Matrix)-instance-method","html_id":"-(other:Matrix)-instance-method","name":"-","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"args_string":"(other : Matrix)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L193","def":{"name":"-","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if column_count != other.column_count\n raise(\"Dimension mismatch\")\nend\nrows = Array.new(row_count) do |i|\n Vector.new(other.column_count) do |j|\n self[i, j] - other[i, j]\n end\nend\nreturn Matrix.new(rows, other.column_count)\n"}},{"id":"/(other:Matrix)-instance-method","html_id":"/(other:Matrix)-instance-method","name":"/","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"args_string":"(other : Matrix)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L210","def":{"name":"/","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"self * other.inverse"}},{"id":"/(vec:Indexable)-instance-method","html_id":"/(vec:Indexable)-instance-method","name":"/","doc":null,"summary":null,"abstract":false,"args":[{"name":"vec","doc":null,"default_value":"","external_name":"vec","restriction":"Indexable"}],"args_string":"(vec : Indexable)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L214","def":{"name":"/","args":[{"name":"vec","doc":null,"default_value":"","external_name":"vec","restriction":"Indexable"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"rows = self.rows.map do |row|\n row.map do |e|\n e / other\n end\nend\nreturn new_matrix(rows, column_count)\n"}},{"id":"==(other:Matrix)-instance-method","html_id":"==(other:Matrix)-instance-method","name":"==","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"args_string":"(other : Matrix)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L221","def":{"name":"==","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if (Matrix === other) && (column_count == other.column_count)\nelse\n return false\nend\nrows == other.rows\n"}},{"id":"[](row:Int,col:Int)-instance-method","html_id":"[](row:Int,col:Int)-instance-method","name":"[]","doc":"Returns element `(row, col)` of the matrix. Throws error on index error.","summary":"

Returns element (row, col) of the matrix.

","abstract":false,"args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":"Int"},{"name":"col","doc":null,"default_value":"","external_name":"col","restriction":"Int"}],"args_string":"(row : Int, col : Int)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L228","def":{"name":"[]","args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":"Int"},{"name":"col","doc":null,"default_value":"","external_name":"col","restriction":"Int"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"self[row][col]"}},{"id":"[]?(row:Int,col:Int)-instance-method","html_id":"[]?(row:Int,col:Int)-instance-method","name":"[]?","doc":"Returns element `(row, col)` of the matrix, or nil if the index is not found.","summary":"

Returns element (row, col) of the matrix, or nil if the index is not found.

","abstract":false,"args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":"Int"},{"name":"col","doc":null,"default_value":"","external_name":"col","restriction":"Int"}],"args_string":"(row : Int, col : Int)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L233","def":{"name":"[]?","args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":"Int"},{"name":"col","doc":null,"default_value":"","external_name":"col","restriction":"Int"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"v = fetch(row) do\n nil\nend\nif v.nil?\nelse\n v[col]?\nend\n"}},{"id":"adjugate-instance-method","html_id":"adjugate-instance-method","name":"adjugate","doc":"Returns the adjugate of the matrix.","summary":"

Returns the adjugate of the matrix.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L239","def":{"name":"adjugate","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if square?\nelse\n raise(\"Dimention mismatch: `Matrix#adjugate` requires a square matrix.\")\nend\nMatrix.build(row_count, column_count) do |row, column|\n cofactor(column, row)\nend\n"}},{"id":"cofactor(row,column)-instance-method","html_id":"cofactor(row,column)-instance-method","name":"cofactor","doc":"Returns the (row, column) cofactor which is obtained by multiplying the first minor by (-1)**(row + column)","summary":"

Returns the (row, column) cofactor which is obtained by multiplying the first minor by (-1)**(row + column)

","abstract":false,"args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":""},{"name":"column","doc":null,"default_value":"","external_name":"column","restriction":""}],"args_string":"(row, column)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L247","def":{"name":"cofactor","args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":""},{"name":"column","doc":null,"default_value":"","external_name":"column","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if empty?\n raise(\"cofactor of empty matrix is not defined\")\nend\nif square?\nelse\n raise(\"Dimention mismatch: `Matrix#cofactor` requires a square matrix.\")\nend\ndet_of_minor = (first_minor(row, column)).determinant\ndet_of_minor * ((-1.0) ** (row + column))\n"}},{"id":"column(j,&block)-instance-method","html_id":"column(j,&block)-instance-method","name":"column","doc":"Iterates over the specified column in the matrix, returning the Vector's items.","summary":"

Iterates over the specified column in the matrix, returning the Vector's items.

","abstract":false,"args":[{"name":"j","doc":null,"default_value":"","external_name":"j","restriction":""}],"args_string":"(j, &block)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L274","def":{"name":"column","args":[{"name":"j","doc":null,"default_value":"","external_name":"j","restriction":""}],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"if j >= column_count || j < (-column_count)\n return self\nend\nrow_count.times do |i|\n yield rows[i][j]\nend\nself\n"}},{"id":"column(j)-instance-method","html_id":"column(j)-instance-method","name":"column","doc":"Returns column vector number `j` of the matrix as a `Vector` (starting at 0 like an array).","summary":"

Returns column vector number j of the matrix as a Vector (starting at 0 like an array).

","abstract":false,"args":[{"name":"j","doc":null,"default_value":"","external_name":"j","restriction":""}],"args_string":"(j)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L265","def":{"name":"column","args":[{"name":"j","doc":null,"default_value":"","external_name":"j","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if j >= column_count || j < (-column_count)\n raise(\"Index out of range\")\nend\ncol = Array(Float64).new(row_count) do |i|\n rows[i][j]\nend\nVector.create(col)\n"}},{"id":"column?(j)-instance-method","html_id":"column?(j)-instance-method","name":"column?","doc":"Returns column vector number `j` of the matrix as a `Vector` (starting at 0 like an array).","summary":"

Returns column vector number j of the matrix as a Vector (starting at 0 like an array).

","abstract":false,"args":[{"name":"j","doc":null,"default_value":"","external_name":"j","restriction":""}],"args_string":"(j)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L256","def":{"name":"column?","args":[{"name":"j","doc":null,"default_value":"","external_name":"j","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if j >= column_count || j < (-column_count)\n return nil\nend\ncol = Array(Float64).new(row_count) do |i|\n rows[i][j]\nend\nVector.create(col)\n"}},{"id":"column_count:Int32-instance-method","html_id":"column_count:Int32-instance-method","name":"column_count","doc":null,"summary":null,"abstract":false,"args":[],"args_string":" : Int32","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L11","def":{"name":"column_count","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Int32","visibility":"Public","body":"@column_count"}},{"id":"column_vectors-instance-method","html_id":"column_vectors-instance-method","name":"column_vectors","doc":"Returns an array of the column vectors of the matrix. See `Vector`.","summary":"

Returns an array of the column vectors of the matrix.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L283","def":{"name":"column_vectors","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Array(Vector).new(column_count) do |i|\n column(i)\nend"}},{"id":"determinant-instance-method","html_id":"determinant-instance-method","name":"determinant","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L354","def":{"name":"determinant","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if square?\nelse\n raise(\"Dimention mismatch: `Matrix#determinant` requires a square matrix.\")\nend\nm = rows\ncase row_count\nwhen 0\n +1\nwhen 1\n +m[0][0]\nwhen 2\n ((+m[0][0]) * m[1][1]) - (m[0][1] * m[1][0])\nwhen 3\n m0, m1, m2 = m\n (((((((+m0[0]) * m1[1]) * m2[2]) - ((m0[0] * m1[2]) * m2[1])) - ((m0[1] * m1[0]) * m2[2])) + ((m0[1] * m1[2]) * m2[0])) + ((m0[2] * m1[0]) * m2[1])) - ((m0[2] * m1[1]) * m2[0])\nwhen 4\n m0, m1, m2, m3 = m\n ((((((((((((((((((((((((((+m0[0]) * m1[1]) * m2[2]) * m3[3]) - (((m0[0] * m1[1]) * m2[3]) * m3[2])) - (((m0[0] * m1[2]) * m2[1]) * m3[3])) + (((m0[0] * m1[2]) * m2[3]) * m3[1])) + (((m0[0] * m1[3]) * m2[1]) * m3[2])) - (((m0[0] * m1[3]) * m2[2]) * m3[1])) - (((m0[1] * m1[0]) * m2[2]) * m3[3])) + (((m0[1] * m1[0]) * m2[3]) * m3[2])) + (((m0[1] * m1[2]) * m2[0]) * m3[3])) - (((m0[1] * m1[2]) * m2[3]) * m3[0])) - (((m0[1] * m1[3]) * m2[0]) * m3[2])) + (((m0[1] * m1[3]) * m2[2]) * m3[0])) + (((m0[2] * m1[0]) * m2[1]) * m3[3])) - (((m0[2] * m1[0]) * m2[3]) * m3[1])) - (((m0[2] * m1[1]) * m2[0]) * m3[3])) + (((m0[2] * m1[1]) * m2[3]) * m3[0])) + (((m0[2] * m1[3]) * m2[0]) * m3[1])) - (((m0[2] * m1[3]) * m2[1]) * m3[0])) - (((m0[3] * m1[0]) * m2[1]) * m3[2])) + (((m0[3] * m1[0]) * m2[2]) * m3[1])) + (((m0[3] * m1[1]) * m2[0]) * m3[2])) - (((m0[3] * m1[1]) * m2[2]) * m3[0])) - (((m0[3] * m1[2]) * m2[0]) * m3[1])) + (((m0[3] * m1[2]) * m2[1]) * m3[0])\nelse\n determinant_bareiss\nend\n"}},{"id":"first_minor(row,column)-instance-method","html_id":"first_minor(row,column)-instance-method","name":"first_minor","doc":null,"summary":null,"abstract":false,"args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":""},{"name":"column","doc":null,"default_value":"","external_name":"column","restriction":""}],"args_string":"(row, column)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L429","def":{"name":"first_minor","args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":""},{"name":"column","doc":null,"default_value":"","external_name":"column","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if empty?\n raise(\"first_minor of empty matrix is not defined\")\nend\nif 0 <= row && row < row_count\nelse\n raise(ArgumentError.new(\"invalid row (#{row.inspect} for 0..#{row_count - 1})\"))\nend\nif 0 <= column && column < column_count\nelse\n raise(ArgumentError.new(\"invalid column (#{column.inspect} for 0..#{column_count - 1})\"))\nend\narrays = to_a.map(&.to_a)\narrays.delete_at(row)\narrays.each do |array|\n array.delete_at(column)\nend\nMatrix.new(arrays, column_count - 1)\n"}},{"id":"inverse-instance-method","html_id":"inverse-instance-method","name":"inverse","doc":"Returns the inverse of the matrix.","summary":"

Returns the inverse of the matrix.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L304","def":{"name":"inverse","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if square?\nelse\n if square?\n else\n raise(\"Dimention mismatch: `Matrix#inverse` requires a square matrix.\")\n end\nend\n(Matrix.identity(row_count)).inverse_from(self)\n"}},{"id":"laplace_expansion(*,row=nil,column=nil)-instance-method","html_id":"laplace_expansion(*,row=nil,column=nil)-instance-method","name":"laplace_expansion","doc":"Returns the Laplace expansion along given row or column.","summary":"

Returns the Laplace expansion along given row or column.

","abstract":false,"args":[{"name":"","doc":null,"default_value":"","external_name":"","restriction":""},{"name":"row","doc":null,"default_value":"nil","external_name":"row","restriction":""},{"name":"column","doc":null,"default_value":"nil","external_name":"column","restriction":""}],"args_string":"(*, row = nil, column = nil)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L450","def":{"name":"laplace_expansion","args":[{"name":"","doc":null,"default_value":"","external_name":"","restriction":""},{"name":"row","doc":null,"default_value":"nil","external_name":"row","restriction":""},{"name":"column","doc":null,"default_value":"nil","external_name":"column","restriction":""}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"num = row || column\nif (!num) || (row && column)\n raise(ArgumentError.new(\"exactly one the row or column arguments must be specified\"))\nend\nif square?\nelse\n raise(\"Dimention mismatch: `Matrix#determinant` requires a square matrix.\")\nend\nif empty?\n raise(\"laplace_expansion of empty matrix is not defined\")\nend\nif 0 <= num && num < row_count\nelse\n raise(ArgumentError.new(\"invalid num (#{num.inspect} for 0..#{row_count - 1})\"))\nend\nif row\n (row(num)).map_with_index do |e, k|\n e * (cofactor(num, k))\n end.reduce(&.+)\nelse\n (column(num)).map_with_index do |e, k|\n e * (cofactor(k, num))\n end.reduce(&.+)\nend\n"}},{"id":"pretty_print(pp):Nil-instance-method","html_id":"pretty_print(pp):Nil-instance-method","name":"pretty_print","doc":null,"summary":null,"abstract":false,"args":[{"name":"pp","doc":null,"default_value":"","external_name":"pp","restriction":""}],"args_string":"(pp) : Nil","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L516","def":{"name":"pretty_print","args":[{"name":"pp","doc":null,"default_value":"","external_name":"pp","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Nil","visibility":"Public","body":"pp.list(\"[\", self, \"]\") do |vec|\n pp.group do\n vec.to_a.pretty_print(pp)\n end\nend"}},{"id":"row(i,&block)-instance-method","html_id":"row(i,&block)-instance-method","name":"row","doc":null,"summary":null,"abstract":false,"args":[{"name":"i","doc":null,"default_value":"","external_name":"i","restriction":""}],"args_string":"(i, &block)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L475","def":{"name":"row","args":[{"name":"i","doc":null,"default_value":"","external_name":"i","restriction":""}],"double_splat":null,"splat_index":null,"yields":0,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":""},"return_type":"","visibility":"Public","body":"(@rows.fetch(i) do\n return self\nend).each(&block)\nself\n"}},{"id":"row(i)-instance-method","html_id":"row(i)-instance-method","name":"row","doc":null,"summary":null,"abstract":false,"args":[{"name":"i","doc":null,"default_value":"","external_name":"i","restriction":""}],"args_string":"(i)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L480","def":{"name":"row","args":[{"name":"i","doc":null,"default_value":"","external_name":"i","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.create(rows.fetch(i) do\n [] of Float64\nend)"}},{"id":"row_count:Int32-instance-method","html_id":"row_count:Int32-instance-method","name":"row_count","doc":null,"summary":null,"abstract":false,"args":[],"args_string":" : Int32","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L13","def":{"name":"row_count","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Int32","visibility":"Public","body":"@row_count"}},{"id":"rows-instance-method","html_id":"rows-instance-method","name":"rows","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L484","def":{"name":"rows","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"rows = [] of Vector\nrow_count.times do |i|\n rows << self[i - 1]\nend\nrows\n"}},{"id":"square?-instance-method","html_id":"square?-instance-method","name":"square?","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L492","def":{"name":"square?","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"row_count == column_count"}},{"id":"to_s(io)-instance-method","html_id":"to_s(io)-instance-method","name":"to_s","doc":null,"summary":null,"abstract":false,"args":[{"name":"io","doc":null,"default_value":"","external_name":"io","restriction":""}],"args_string":"(io)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L502","def":{"name":"to_s","args":[{"name":"io","doc":null,"default_value":"","external_name":"io","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if empty?\n \"Matrix.empty(#{row_count}, #{column_count})\"\nelse\n io << \"Matrix[\"\n io << (map do |row|\n (\"{\" + (row.to_a.map do |e|\n e.to_s\n end.join(\", \"))) + \"}\"\n end.join(\", \"))\n io << \"]\"\nend"}},{"id":"transpose-instance-method","html_id":"transpose-instance-method","name":"transpose","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L496","def":{"name":"transpose","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if row_count.zero?\n return Matrix.empty(column_count, 0)\nend\ntransposed = rows.map do |v|\n v.to_a\nend.transpose\nMatrix.new(transposed, row_count)\n"}},{"id":"unsafe_fetch(index:Int)-instance-method","html_id":"unsafe_fetch(index:Int)-instance-method","name":"unsafe_fetch","doc":null,"summary":null,"abstract":false,"args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"}],"args_string":"(index : Int)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/matrix.cr#L525","def":{"name":"unsafe_fetch","args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@buffer[index]"}}],"macros":[],"types":[]},{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra/NDArray","path":"Apatite/LinearAlgebra/NDArray.html","kind":"class","full_name":"Apatite::LinearAlgebra::NDArray","name":"NDArray","abstract":false,"superclass":{"html_id":"github.com/watzon/apatite/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"github.com/watzon/apatite/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"github.com/watzon/apatite/Indexable","kind":"module","full_name":"Indexable","name":"Indexable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Iterable","kind":"module","full_name":"Iterable","name":"Iterable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"github.com/watzon/apatite/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"apatite/linear_algebra/ndarray.cr","line_number":2,"url":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/ndarray.cr"}],"repository_name":"github.com/watzon/apatite","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[{"html_id":"github.com/watzon/apatite/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Indexable","kind":"module","full_name":"Indexable","name":"Indexable"}],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra","kind":"module","full_name":"Apatite::LinearAlgebra","name":"LinearAlgebra"},"doc":null,"summary":null,"class_methods":[],"constructors":[{"id":"new(data:Array(Number),shape:Array(Int32)?=nil)-class-method","html_id":"new(data:Array(Number),shape:Array(Int32)?=nil)-class-method","name":"new","doc":null,"summary":null,"abstract":false,"args":[{"name":"data","doc":null,"default_value":"","external_name":"data","restriction":"Array(Number)"},{"name":"shape","doc":null,"default_value":"nil","external_name":"shape","restriction":"Array(Int32) | ::Nil"}],"args_string":"(data : Array(Number), shape : Array(Int32)? = nil)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/ndarray.cr#L18","def":{"name":"new","args":[{"name":"data","doc":null,"default_value":"","external_name":"data","restriction":"Array(Number)"},{"name":"shape","doc":null,"default_value":"nil","external_name":"shape","restriction":"Array(Int32) | ::Nil"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"_ = allocate\n_.initialize(data, shape)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"id":"[](*args,**options)-instance-method","html_id":"[](*args,**options)-instance-method","name":"[]","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/ndarray.cr#L11","def":{"name":"[]","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@data[*args, **options]"}},{"id":"[](*args,**options,&block)-instance-method","html_id":"[](*args,**options,&block)-instance-method","name":"[]","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options, &block)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/ndarray.cr#L11","def":{"name":"[]","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"@data[*args, **options] do |*yield_args|\n yield *yield_args\nend"}},{"id":"[]=(*args,**options)-instance-method","html_id":"[]=(*args,**options)-instance-method","name":"[]=","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/ndarray.cr#L13","def":{"name":"[]=","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@data[*args] = **options"}},{"id":"[]?(*args,**options)-instance-method","html_id":"[]?(*args,**options)-instance-method","name":"[]?","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/ndarray.cr#L12","def":{"name":"[]?","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@data[*args, **options]?"}},{"id":"[]?(*args,**options,&block)-instance-method","html_id":"[]?(*args,**options,&block)-instance-method","name":"[]?","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options, &block)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/ndarray.cr#L12","def":{"name":"[]?","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"@data[*args, **options]? do |*yield_args|\n yield *yield_args\nend"}},{"id":"abs-instance-method","html_id":"abs-instance-method","name":"abs","doc":"Returns the absolute value of every item in the array","summary":"

Returns the absolute value of every item in the array

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/ndarray.cr#L24","def":{"name":"abs","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"map do |e|\n e.abs\nend"}},{"id":"acos-instance-method","html_id":"acos-instance-method","name":"acos","doc":"Returns the arccosine of each element in the current array.","summary":"

Returns the arccosine of each element in the current array.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/ndarray.cr#L29","def":{"name":"acos","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":""}},{"id":"data:Array(Float64)-instance-method","html_id":"data:Array(Float64)-instance-method","name":"data","doc":null,"summary":null,"abstract":false,"args":[],"args_string":" : Array(Float64)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/ndarray.cr#L9","def":{"name":"data","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Array(Float64)","visibility":"Public","body":"@data"}},{"id":"shape:Array(Int32)-instance-method","html_id":"shape:Array(Int32)-instance-method","name":"shape","doc":null,"summary":null,"abstract":false,"args":[],"args_string":" : Array(Int32)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/ndarray.cr#L11","def":{"name":"shape","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Array(Int32)","visibility":"Public","body":"@shape"}},{"id":"size(*args,**options)-instance-method","html_id":"size(*args,**options)-instance-method","name":"size","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/ndarray.cr#L16","def":{"name":"size","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@data.size(*args, **options)"}},{"id":"size(*args,**options,&block)-instance-method","html_id":"size(*args,**options,&block)-instance-method","name":"size","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options, &block)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/ndarray.cr#L16","def":{"name":"size","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"@data.size(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"id":"to_unsafe(*args,**options)-instance-method","html_id":"to_unsafe(*args,**options)-instance-method","name":"to_unsafe","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/ndarray.cr#L15","def":{"name":"to_unsafe","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@data.to_unsafe(*args, **options)"}},{"id":"to_unsafe(*args,**options,&block)-instance-method","html_id":"to_unsafe(*args,**options,&block)-instance-method","name":"to_unsafe","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options, &block)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/ndarray.cr#L15","def":{"name":"to_unsafe","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"@data.to_unsafe(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"id":"unsafe_fetch(*args,**options)-instance-method","html_id":"unsafe_fetch(*args,**options)-instance-method","name":"unsafe_fetch","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/ndarray.cr#L14","def":{"name":"unsafe_fetch","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@data.unsafe_fetch(*args, **options)"}},{"id":"unsafe_fetch(*args,**options,&block)-instance-method","html_id":"unsafe_fetch(*args,**options,&block)-instance-method","name":"unsafe_fetch","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options, &block)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/ndarray.cr#L14","def":{"name":"unsafe_fetch","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"@data.unsafe_fetch(*args, **options) do |*yield_args|\n yield *yield_args\nend"}}],"macros":[],"types":[]},{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra/Vector","path":"Apatite/LinearAlgebra/Vector.html","kind":"class","full_name":"Apatite::LinearAlgebra::Vector","name":"Vector","abstract":false,"superclass":{"html_id":"github.com/watzon/apatite/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"github.com/watzon/apatite/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"github.com/watzon/apatite/Indexable","kind":"module","full_name":"Indexable","name":"Indexable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Iterable","kind":"module","full_name":"Iterable","name":"Iterable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"github.com/watzon/apatite/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"apatite/linear_algebra/vector.cr","line_number":4,"url":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr"}],"repository_name":"github.com/watzon/apatite","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[{"id":"I","name":"I","value":"Vector.create([1.0, 0.0, 0.0])","doc":"Cartesian unit vector I","summary":"

Cartesian unit vector I

"},{"id":"J","name":"J","value":"Vector.create([0.0, 1.0, 0.0])","doc":"Cartesian unit vector J","summary":"

Cartesian unit vector J

"},{"id":"K","name":"K","value":"Vector.create([0.0, 0.0, 1.0])","doc":"Cartesian unit vector K","summary":"

Cartesian unit vector K

"}],"included_modules":[{"html_id":"github.com/watzon/apatite/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Indexable","kind":"module","full_name":"Indexable","name":"Indexable"}],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra","kind":"module","full_name":"Apatite::LinearAlgebra","name":"LinearAlgebra"},"doc":"Represents a mathematical vector, and also constitutes a row or column\nof a `Matrix`","summary":"

Represents a mathematical vector, and also constitutes a row or column of a Matrix

","class_methods":[{"id":"[](*array)-class-method","html_id":"[](*array)-class-method","name":"[]","doc":null,"summary":null,"abstract":false,"args":[{"name":"array","doc":null,"default_value":"","external_name":"array","restriction":""}],"args_string":"(*array)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L156","def":{"name":"[]","args":[{"name":"array","doc":null,"default_value":"","external_name":"array","restriction":""}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.create(array)"}},{"id":"basis(size,index)-class-method","html_id":"basis(size,index)-class-method","name":"basis","doc":"Returns a standard basis n-vector.","summary":"

Returns a standard basis n-vector.

","abstract":false,"args":[{"name":"size","doc":null,"default_value":"","external_name":"size","restriction":""},{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":""}],"args_string":"(size, index)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L138","def":{"name":"basis","args":[{"name":"size","doc":null,"default_value":"","external_name":"size","restriction":""},{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if size < 1\n raise(ArgumentError.new(\"invalid size (#{size} for 1..)\"))\nend\nif 0 <= index && index < size\nelse\n raise(ArgumentError.new(\"invalid index (#{index} for 0...#{size})\"))\nend\nvec = Vector.new(size, 0.0)\nvec[index] = 1.0\nvec\n"}},{"id":"create(elements:Indexable(Number))-class-method","html_id":"create(elements:Indexable(Number))-class-method","name":"create","doc":"Creates a new `Vector` from the elements of another `Indexable`\ncollection.\n\n```\nVector.create([1, 2, 3]) # Vector{1.0, 2.0, 3.0}\n```","summary":"

Creates a new Vector from the elements of another Indexable collection.

","abstract":false,"args":[{"name":"elements","doc":null,"default_value":"","external_name":"elements","restriction":"Indexable(Number)"}],"args_string":"(elements : Indexable(Number))","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L118","def":{"name":"create","args":[{"name":"elements","doc":null,"default_value":"","external_name":"elements","restriction":"Indexable(Number)"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"vec = Vector.new\nelements.each do |el|\n vec.push(el.to_f64)\nend\nvec\n"}},{"id":"ones(n)-class-method","html_id":"ones(n)-class-method","name":"ones","doc":"Create a new vector of size `n` filled with ones.","summary":"

Create a new vector of size n filled with ones.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L152","def":{"name":"ones","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.new(n, 1.0)"}},{"id":"random(n,range=nil)-class-method","html_id":"random(n,range=nil)-class-method","name":"random","doc":"Creates a new `Vector` of size `n` filled with random numbers. A `range`\ncan optionally be passed in if you want to limit the random numbers\nto a given range.","summary":"

Creates a new Vector of size n filled with random numbers.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""},{"name":"range","doc":null,"default_value":"nil","external_name":"range","restriction":""}],"args_string":"(n, range = nil)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L129","def":{"name":"random","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""},{"name":"range","doc":null,"default_value":"nil","external_name":"range","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"vec = Vector.new(n)\nn.times do\n vec.push(rand((range || -1e+1)..1e+1))\nend\nvec\n"}},{"id":"zeros(n)-class-method","html_id":"zeros(n)-class-method","name":"zeros","doc":"Create a new vector of size `n` filled with zeros.","summary":"

Create a new vector of size n filled with zeros.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L147","def":{"name":"zeros","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.new(n, 0.0)"}}],"constructors":[{"id":"build(capacity:Int,&block):self-class-method","html_id":"build(capacity:Int,&block):self-class-method","name":"build","doc":"Creates a new `Vector`, allocating an internal buffer with the given *capacity*,\nand yielding that buffer. The given block must return the desired size of the vector.\n\nThis method is **unsafe**.\n\n```\nVector.build(3) do |buffer|\n LibSome.fill_buffer_and_return_number_of_elements_filled(buffer)\nend\n```","summary":"

Creates a new Vector, allocating an internal buffer with the given capacity, and yielding that buffer.

","abstract":false,"args":[{"name":"capacity","doc":null,"default_value":"","external_name":"capacity","restriction":"Int"}],"args_string":"(capacity : Int, &block) : self","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L106","def":{"name":"build","args":[{"name":"capacity","doc":null,"default_value":"","external_name":"capacity","restriction":"Int"}],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"self","visibility":"Public","body":"vec = Vector.new(capacity)\nvec.size = (yield vec.to_unsafe).to_i\nvec\n"}},{"id":"new(size:Int,value:Float64)-class-method","html_id":"new(size:Int,value:Float64)-class-method","name":"new","doc":"Creates a new `Vector` of the given *size* filled with the same *value* in each position.\n\n```\nVector.new(3, 1.0) # => Vector{1.0, 1.0, 1.0}\n```","summary":"

Creates a new Vector of the given size filled with the same value in each position.

","abstract":false,"args":[{"name":"size","doc":null,"default_value":"","external_name":"size","restriction":"Int"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":"Float64"}],"args_string":"(size : Int, value : Float64)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L63","def":{"name":"new","args":[{"name":"size","doc":null,"default_value":"","external_name":"size","restriction":"Int"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":"Float64"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"_ = allocate\n_.initialize(size, value)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"id":"new(initial_capacity:Int)-class-method","html_id":"new(initial_capacity:Int)-class-method","name":"new","doc":"Creates a new empty `Vector` backed by a buffer that is initially\n`initial_capacity` big.\n\nThe *initial_capacity* is useful to avoid unnecessary reallocations\nof the internal buffer in case of growth. If you have an estimate\nof the maximum number of elements an vector will hold, the vector should\nbe initialized with that capacity for improved performance.\n\n```\nvec = Vector.new(5)\nvec.size # => 0\n```","summary":"

Creates a new empty Vector backed by a buffer that is initially initial_capacity big.

","abstract":false,"args":[{"name":"initial_capacity","doc":null,"default_value":"","external_name":"initial_capacity","restriction":"Int"}],"args_string":"(initial_capacity : Int)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L43","def":{"name":"new","args":[{"name":"initial_capacity","doc":null,"default_value":"","external_name":"initial_capacity","restriction":"Int"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"_ = allocate\n_.initialize(initial_capacity)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"id":"new-class-method","html_id":"new-class-method","name":"new","doc":"Create a new empty `Vector`.","summary":"

Create a new empty Vector.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L25","def":{"name":"new","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"_ = allocate\n_.initialize\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"id":"new(size:Int,&block:Int32->Float64)-class-method","html_id":"new(size:Int,&block:Int32->Float64)-class-method","name":"new","doc":"Creates a new `Vector` of the given *size* and invokes the given block once\nfor each index of `self`, assigning the block's value in that index.\n\n```\nVector.new(3) { |i| (i + 1.0) ** 2.0 } # => Vector{1.0, 4.0, 9.0}\n\nvec = Vector.new(3) { 5.0 }\nvec # => Vector{5.0, 5.0, 5.0}\n```","summary":"

Creates a new Vector of the given size and invokes the given block once for each index of self, assigning the block's value in that index.

","abstract":false,"args":[{"name":"size","doc":null,"default_value":"","external_name":"size","restriction":"Int"}],"args_string":"(size : Int, &block : Int32 -> Float64)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L87","def":{"name":"new","args":[{"name":"size","doc":null,"default_value":"","external_name":"size","restriction":"Int"}],"double_splat":null,"splat_index":null,"yields":1,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":"(Int32 -> Float64)"},"return_type":"","visibility":"Public","body":"Vector.build(size) do |buffer|\n size.to_i.times do |i|\n buffer[i] = yield i\n end\n size\nend"}}],"instance_methods":[{"id":"*(other)-instance-method","html_id":"*(other)-instance-method","name":"*","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"args_string":"(other)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L370","def":{"name":"*","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"multiply(other)"}},{"id":"+(other)-instance-method","html_id":"+(other)-instance-method","name":"+","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"args_string":"(other)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L362","def":{"name":"+","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"add(other)"}},{"id":"-(other)-instance-method","html_id":"-(other)-instance-method","name":"-","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"args_string":"(other)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L366","def":{"name":"-","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"subtract(other)"}},{"id":"<<(value:Float64)-instance-method","html_id":"<<(value:Float64)-instance-method","name":"<<","doc":"Alias for `#push`","summary":"

Alias for #push

","abstract":false,"args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":"Float64"}],"args_string":"(value : Float64)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L349","def":{"name":"<<","args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":"Float64"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"push(value)"}},{"id":"(other)-instance-method","html_id":"(other)-instance-method","name":"<=>","doc":"Combined comparison operator. Returns *0* if `self` equals *other*, *1* if\n`self` is greater than *other* and *-1* if `self` is smaller than *other*.\n\nIt compares the elements of both vectors in the same position using the\n`<=>` operator. As soon as one of such comparisons returns a non-zero\nvalue, that result is the return value of the comparison.\n\nIf all elements are equal, the comparison is based on the size of the vectors.\n\n```\nVector{8.0} <=> Vector(1.0, 2.0, 3.0} # => 1\nVector{2.0} <=> Vector{4.0, 2.0, 3.0} # => -1\nVector{1.0, 2.0} <=> Vector{1.0, 2.0} # => 0\n```","summary":"

Combined comparison operator.

","abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"args_string":"(other)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L339","def":{"name":"<=>","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"min_size = Math.min(size, other.size)\n0.upto(min_size - 1) do |i|\n n = @buffer[i] <=> other.to_unsafe[i]\n if n != 0\n return n\n end\nend\nsize <=> other.size\n"}},{"id":"==(other:Vector)-instance-method","html_id":"==(other:Vector)-instance-method","name":"==","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Vector"}],"args_string":"(other : Vector)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L353","def":{"name":"==","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Vector"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"equals?(other) do |x, y|\n x == y\nend"}},{"id":"[](start:Int,count:Int)-instance-method","html_id":"[](start:Int,count:Int)-instance-method","name":"[]","doc":"Returns count or less (if there aren't enough) elements starting at the\ngiven start index.\n\nNegative indices count backward from the end of the vector (-1 is the last\nelement). Additionally, an empty vector is returned when the starting index\nfor an element range is at the end of the vector.\n\nRaises `IndexError` if the starting index is out of range.\n\n```\nv = Vector{1.0, 2.0, 3.0, 4.0, 5.0}\nv[1, 3] # => Vector{2.0, 3.0, 4.0}\nv[6, 10] # raise IndexError\n```","summary":"

Returns count or less (if there aren't enough) elements starting at the given start index.

","abstract":false,"args":[{"name":"start","doc":null,"default_value":"","external_name":"start","restriction":"Int"},{"name":"count","doc":null,"default_value":"","external_name":"count","restriction":"Int"}],"args_string":"(start : Int, count : Int)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L191","def":{"name":"[]","args":[{"name":"start","doc":null,"default_value":"","external_name":"start","restriction":"Int"},{"name":"count","doc":null,"default_value":"","external_name":"count","restriction":"Int"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if count < 0\n raise(ArgumentError.new(\"Negative count: #{count}\"))\nend\nif start == size\n return Vector.new\nend\nif start < 0\n start = start + size\nend\nif 0 <= start && start <= size\nelse\n raise(IndexError.new)\nend\nif count == 0\n return Vector.new\nend\ncount = Math.min(count, size - start)\nVector.build(count) do |buffer|\n buffer.copy_from(@buffer + start, count)\n count\nend\n"}},{"id":"[](range:Range(Int,Int))-instance-method","html_id":"[](range:Range(Int,Int))-instance-method","name":"[]","doc":"Returns all elements that are within the given range.\n\nNegative indices count backward from the end of the vector (-1 is the last\nelement). Additionally, an empty vector is returned when the starting index\nfor an element range is at the end of the vector.\n\nRaises `IndexError` if the starting index is out of range.\n\n```\nv = Vector{1.0, 2.0, 3.0, 4.0, 5.0}\nv[1..3] # => Vector{2.0, 3.0, 4.0}\nv[6..10] # raise IndexError\n```","summary":"

Returns all elements that are within the given range.

","abstract":false,"args":[{"name":"range","doc":null,"default_value":"","external_name":"range","restriction":"Range(Int, Int)"}],"args_string":"(range : Range(Int, Int))","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L173","def":{"name":"[]","args":[{"name":"range","doc":null,"default_value":"","external_name":"range","restriction":"Range(Int, Int)"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"self[*Indexable.range_to_index_and_count(range, size)]"}},{"id":"[]=(index:Int,count:Int,values:Vector)-instance-method","html_id":"[]=(index:Int,count:Int,values:Vector)-instance-method","name":"[]=","doc":"Replaces a subrange with the elements of the given vector.\n\n```\nvec = Vector{1.0, 2.0, 3.0, 4.0, 5.0}\nvec[1, 3] = Vector{6.0, 7.0, 8.0}\nvec # = Vector{1.0, 6.0, 7.0, 8.0, 5.0}\n\nvec = Vector{1.0, 2.0, 3.0, 4.0, 5.0}\nvec[1, 3] = Vector{6.0, 7.0}\nvec # = Vector{1.0, 6.0, 7.0, 5.0}\n```","summary":"

Replaces a subrange with the elements of the given vector.

","abstract":false,"args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"},{"name":"count","doc":null,"default_value":"","external_name":"count","restriction":"Int"},{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":"Vector"}],"args_string":"(index : Int, count : Int, values : Vector)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L297","def":{"name":"[]=","args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"},{"name":"count","doc":null,"default_value":"","external_name":"count","restriction":"Int"},{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":"Vector"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if count < 0\n raise(ArgumentError.new(\"Negative count: #{count}\"))\nend\nindex = check_index_out_of_bounds(index)\ncount = ((index + count) <= size) ? count : size - index\ndiff = values.size - count\nif diff == 0\n (@buffer + index).copy_from(values.to_unsafe, values.size)\nelse\n if diff < 0\n diff = -diff\n (@buffer + index).copy_from(values.to_unsafe, values.size)\n ((@buffer + index) + values.size).move_from((@buffer + index) + count, (size - index) - count)\n ((@buffer + @size) - diff).clear(diff)\n @size = @size - diff\n else\n resize_to_capacity(Math.pw2ceil(@size + diff))\n ((@buffer + index) + values.size).move_from((@buffer + index) + count, (size - index) - count)\n (@buffer + index).copy_from(values.to_unsafe, values.size)\n @size = @size + diff\n end\nend\nvalues\n"}},{"id":"[]=(index:Int,count:Int,value)-instance-method","html_id":"[]=(index:Int,count:Int,value)-instance-method","name":"[]=","doc":"Replaces a subrange with a single value. All elements in the range\n`index...index+count` are removed and replaced by a single element\n*value*.\n\nIf *count* is zero, *value* is inserted at *index*.\n\nNegative values of *index* count from the end of the vector.\n\n```\nvec = Vector{1.0, 2.0, 3.0, 4.0, 5.0}\nvec[1, 3] = 6.0\nvec # => Vector{1.0, 6.0, 5.0}\n\nvec = Vector{1.0, 2.0, 3.0, 4.0, 5.0}\nvec[1, 0] = 6.0\nvec # => Vector{1.0, 6.0, 2.0, 3.0, 4.0, 5.0}\n```","summary":"

Replaces a subrange with a single value.

","abstract":false,"args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"},{"name":"count","doc":null,"default_value":"","external_name":"count","restriction":"Int"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(index : Int, count : Int, value)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L248","def":{"name":"[]=","args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"},{"name":"count","doc":null,"default_value":"","external_name":"count","restriction":"Int"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if count < 0\n raise(ArgumentError.new(\"Negative count: #{count}\"))\nend\nvalue = value.to_f64\nindex = check_index_out_of_bounds(index)\ncount = ((index + count) <= size) ? count : size - index\ncase count\nwhen 0\n insert(index, value)\nwhen 1\n @buffer[index] = value\nelse\n diff = count - 1\n ((@buffer + index) + 1).move_from((@buffer + index) + count, (size - index) - count)\n ((@buffer + @size) - diff).clear(diff)\n @buffer[index] = value\n @size = @size - diff\nend\nvalue\n"}},{"id":"[]=(index:Int,value)-instance-method","html_id":"[]=(index:Int,value)-instance-method","name":"[]=","doc":"Sets the given value at the given index.\n\nNegative indices can be used to start counting from the end of the array.\nRaises `IndexError` if trying to set an element outside the array's range.\n\n```\nvec = Vector{1.0, 2.0, 3.0}\nvec[0] = 5.0\np vec # => Vec{5.0, 2.0, 3.0}\n\nvec[3] = 5.0 # raises IndexError\n```","summary":"

Sets the given value at the given index.

","abstract":false,"args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(index : Int, value)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L226","def":{"name":"[]=","args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"index = check_index_out_of_bounds(index)\n@buffer[index] = value.to_f64\n"}},{"id":"[]=(range:Range(Int,Int),value)-instance-method","html_id":"[]=(range:Range(Int,Int),value)-instance-method","name":"[]=","doc":"Replaces a subrange with a single value.\n\n```\nvec = Vector{1.0, 2.0, 3.0, 4.0, 5.0}\nvec[1..3] = 6.0\nvec # = Vector{1.0, 6.0, 5.0}\n\nvec = Vector{1.0, 2.0, 3.0, 4.0, 5.0}\nvec[1...1] = 6\nvec # = Vector{1.0, 6.0, 2.0, 3.0, 4.0, 5.0}\n```","summary":"

Replaces a subrange with a single value.

","abstract":false,"args":[{"name":"range","doc":null,"default_value":"","external_name":"range","restriction":"Range(Int, Int)"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(range : Range(Int, Int), value)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L282","def":{"name":"[]=","args":[{"name":"range","doc":null,"default_value":"","external_name":"range","restriction":"Range(Int, Int)"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"self[*Indexable.range_to_index_and_count(range, size)] = value.to_f64"}},{"id":"add(value)-instance-method","html_id":"add(value)-instance-method","name":"add","doc":"When the input is a number, this returns the result of adding\nit to all vector elements. When it's a vector, the vectors\nwill be added together.","summary":"

When the input is a number, this returns the result of adding it to all vector elements.

","abstract":false,"args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(value)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L488","def":{"name":"add","args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"run_binary_op(value) do |a, b|\n a + b\nend"}},{"id":"angle_from(vector)-instance-method","html_id":"angle_from(vector)-instance-method","name":"angle_from","doc":"Returns the angle between this vector and another in radians.\nIf the vectors are mirrored across their axes this will return `nil`.","summary":"

Returns the angle between this vector and another in radians.

","abstract":false,"args":[{"name":"vector","doc":null,"default_value":"","external_name":"vector","restriction":""}],"args_string":"(vector)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L440","def":{"name":"angle_from","args":[{"name":"vector","doc":null,"default_value":"","external_name":"vector","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"v = vector.is_a?(Vector) ? vector : Vector.create(vector)\nif size == v.size\nelse\n raise(\"Cannot compute the angle between vectors with different dimensionality\")\nend\ndot = 0_f64\nmod1 = 0_f64\nmod2 = 0_f64\n(zip(vector)).each do |x, v|\n dot = dot + (x * v)\n mod1 = mod1 + (x * x)\n mod2 = mod2 + (v * v)\nend\nmod1 = Math.sqrt(mod1)\nmod2 = Math.sqrt(mod2)\nif (mod2 * mod2) == 0\n return 0.0\nend\ntheta = (dot / (mod1 * mod2)).clamp(-1, 1)\nMath.acos(theta)\n"}},{"id":"antiparallel_to?(vector)-instance-method","html_id":"antiparallel_to?(vector)-instance-method","name":"antiparallel_to?","doc":"Returns whether the vectors are antiparallel to each other.","summary":"

Returns whether the vectors are antiparallel to each other.

","abstract":false,"args":[{"name":"vector","doc":null,"default_value":"","external_name":"vector","restriction":""}],"args_string":"(vector)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L475","def":{"name":"antiparallel_to?","args":[{"name":"vector","doc":null,"default_value":"","external_name":"vector","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"angle = angle_from(vector)\n(angle - Math::PI).abs <= Apatite.precision\n"}},{"id":"augment(elements)-instance-method","html_id":"augment(elements)-instance-method","name":"augment","doc":"Returns a new vector with the provided `elements` concatenated\non the end.","summary":"

Returns a new vector with the provided elements concatenated on the end.

","abstract":false,"args":[{"name":"elements","doc":null,"default_value":"","external_name":"elements","restriction":""}],"args_string":"(elements)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L556","def":{"name":"augment","args":[{"name":"elements","doc":null,"default_value":"","external_name":"elements","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"elements = elements.is_a?(Vector) ? elements : Vector.create(elements)\nconcat(elements)\n"}},{"id":"chomp(n)-instance-method","html_id":"chomp(n)-instance-method","name":"chomp","doc":"Returns a new vector with the first `n` elements removed from\nthe beginning.","summary":"

Returns a new vector with the first n elements removed from the beginning.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L541","def":{"name":"chomp","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"elements = [] of Float64\neach_with_index do |e, i|\n if i >= n\n elements << e\n end\nend\nVector.create(elements)\n"}},{"id":"clear-instance-method","html_id":"clear-instance-method","name":"clear","doc":"Removes all elements from self.\n\n```\nvec = Vector{1.0, 2.0, 3.0}\nvec.clear # => Vector{}\n```","summary":"

Removes all elements from self.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L782","def":{"name":"clear","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@buffer.clear(@size)\n@size = 0\nself\n"}},{"id":"clone-instance-method","html_id":"clone-instance-method","name":"clone","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L374","def":{"name":"clone","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.create(@elements.clone)"}},{"id":"concat(other:Vector)-instance-method","html_id":"concat(other:Vector)-instance-method","name":"concat","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Vector"}],"args_string":"(other : Vector)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L731","def":{"name":"concat","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Vector"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"other_size = other.size\nnew_size = size + other_size\nif new_size > @capacity\n resize_to_capacity(Math.pw2ceil(new_size))\nend\n(@buffer + @size).copy_from(other.to_unsafe, other_size)\n@size = new_size\nself\n"}},{"id":"covector-instance-method","html_id":"covector-instance-method","name":"covector","doc":"Creates a single-row matrix from this vector.","summary":"

Creates a single-row matrix from this vector.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L601","def":{"name":"covector","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.row_vector(self)"}},{"id":"cross(*vs)-instance-method","html_id":"cross(*vs)-instance-method","name":"cross","doc":"Returns the cross product of this vector with the others.\n\n```\nv1 = Vector{1.0, 0.0, 0.0}\nv2 = Vector{0.0, 1.0, 0.0}\nv1.cross(v2) => Vector{0.0, 0.0, 1.0}\n```","summary":"

Returns the cross product of this vector with the others.

","abstract":false,"args":[{"name":"vs","doc":null,"default_value":"","external_name":"vs","restriction":""}],"args_string":"(*vs)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L518","def":{"name":"cross","args":[{"name":"vs","doc":null,"default_value":"","external_name":"vs","restriction":""}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if size >= 2\nelse\n raise(\"cross product is not defined on vectors of dimension #{size}\")\nend\nif vs.size == (size - 2)\nelse\n raise(ArgumentError.new(\"wrong number of arguments (#{vs.size} for #{size - 2})\"))\nend\nvs.each do |v|\n if v.size == size\n else\n raise(\"Dimension mismatch. Vectors not all the same size.\")\n end\nend\ncase size\nwhen 2\n Vector[-@buffer[1], @buffer[0]]\nwhen 3\n v = vs[0]\n Vector[(v[2] * @buffer[1]) - (v[1] * @buffer[2]), (v[0] * @buffer[2]) - (v[2] * @buffer[0]), (v[1] * @buffer[0]) - (v[0] * @buffer[1])]\nelse\nend\n"}},{"id":"distance_from(obj)-instance-method","html_id":"distance_from(obj)-instance-method","name":"distance_from","doc":"Gets this vector's distance from the argument, when considered\na point in space.","summary":"

Gets this vector's distance from the argument, when considered a point in space.

","abstract":false,"args":[{"name":"obj","doc":null,"default_value":"","external_name":"obj","restriction":""}],"args_string":"(obj)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L629","def":{"name":"distance_from","args":[{"name":"obj","doc":null,"default_value":"","external_name":"obj","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if object.is_a?(Plane) || object.is_a?(Line)\n return object.distance_from(self)\nend\nv = elements.is_a?(Vector) ? elements.elements : elements\nif v.size == @elements.size\nelse\n return nil\nend\nsum = 0\npart = 0\neach_with_index do |x, i|\n part = x - v[i - 1]\n sum = sum + (part * part)\nend\nMath.sqrt(sum)\n"}},{"id":"dot(other)-instance-method","html_id":"dot(other)-instance-method","name":"dot","doc":"Get the scalar (dot) product of this vector with `vector`.\n\n[https://en.wikipedia.org/wiki/Scalar_product](https://en.wikipedia.org/wiki/Scalar_product)","summary":"

Get the scalar (dot) product of this vector with vector.

","abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"args_string":"(other)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L574","def":{"name":"dot","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"other = other.is_a?(Vector) ? other : Vector.create(other)\nif size == other.size\nelse\n raise(\"Cannot compute the dot product of vectors with different dimensionality\")\nend\nproduct = 0\n(0...size).each do |i|\n product = product + (self[i] * other[i])\nend\nproduct\n"}},{"id":"e(i)-instance-method","html_id":"e(i)-instance-method","name":"e","doc":"Returns the `ith` element of the vector. Returns `nil` if `i`\nis out of bounds. Indexing starts from 1.","summary":"

Returns the ith element of the vector.

","abstract":false,"args":[{"name":"i","doc":null,"default_value":"","external_name":"i","restriction":""}],"args_string":"(i)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L426","def":{"name":"e","args":[{"name":"i","doc":null,"default_value":"","external_name":"i","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"(i < 1 || i > @size) ? nil : self[i - 1]"}},{"id":"independent?(*vs)-instance-method","html_id":"independent?(*vs)-instance-method","name":"independent?","doc":"Returns true if all vectors are linearly independent.","summary":"

Returns true if all vectors are linearly independent.

","abstract":false,"args":[{"name":"vs","doc":null,"default_value":"","external_name":"vs","restriction":""}],"args_string":"(*vs)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L384","def":{"name":"independent?","args":[{"name":"vs","doc":null,"default_value":"","external_name":"vs","restriction":""}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"vs.each do |v|\n if v.size == vs.first.size\n else\n raise(\"Dimension mismatch. Vectors not all the same size.\")\n end\nend\nif vs.size > sv.first.size\n return false\nend\nMatrix[*vs].rank.equal?(vs.count)\n"}},{"id":"lies_in(plane)-instance-method","html_id":"lies_in(plane)-instance-method","name":"lies_in","doc":"Returns true if the vector is a point on the given plane.","summary":"

Returns true if the vector is a point on the given plane.

","abstract":false,"args":[{"name":"plane","doc":null,"default_value":"","external_name":"plane","restriction":""}],"args_string":"(plane)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L654","def":{"name":"lies_in","args":[{"name":"plane","doc":null,"default_value":"","external_name":"plane","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"plane.contains(self)"}},{"id":"lies_on(line)-instance-method","html_id":"lies_on(line)-instance-method","name":"lies_on","doc":"Returns true if the vector is a point on the given line","summary":"

Returns true if the vector is a point on the given line

","abstract":false,"args":[{"name":"line","doc":null,"default_value":"","external_name":"line","restriction":""}],"args_string":"(line)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L649","def":{"name":"lies_on","args":[{"name":"line","doc":null,"default_value":"","external_name":"line","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"line.contains(self)"}},{"id":"log-instance-method","html_id":"log-instance-method","name":"log","doc":"Return a new `Vector` with the log of every item in `self`.","summary":"

Return a new Vector with the log of every item in self.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L562","def":{"name":"log","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"map do |x|\n Math.log(x)\nend"}},{"id":"magnitude-instance-method","html_id":"magnitude-instance-method","name":"magnitude","doc":"Returns the magnitude/euclidian norm of this vector.\n\n[https://en.wikipedia.org/wiki/Euclidean_distance](https://en.wikipedia.org/wiki/Euclidean_distance)","summary":"

Returns the magnitude/euclidian norm of this vector.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L419","def":{"name":"magnitude","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"sum = reduce(0.0) do |acc, e|\n acc = acc + (e * e)\nend\nMath.sqrt(sum)\n"}},{"id":"map(&block)-instance-method","html_id":"map(&block)-instance-method","name":"map","doc":"Invokes the given block for each element of `self`.","summary":"

Invokes the given block for each element of self.

","abstract":false,"args":[],"args_string":"(&block)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L379","def":{"name":"map","args":[],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.new(size) do |i|\n yield @buffer[i]\nend"}},{"id":"map!(&block)-instance-method","html_id":"map!(&block)-instance-method","name":"map!","doc":"Invokes the given block for each element of `self`, replacing the element\nwith the value returned by the block. Returns `self`.\n\n```\nvec = Vector{1.0, 2.0, 3.0}\nvec.map! { |x| x * x }\na # => Vector{1.0, 4.0, 9.0}\n```","summary":"

Invokes the given block for each element of self, replacing the element with the value returned by the block.

","abstract":false,"args":[],"args_string":"(&block)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L400","def":{"name":"map!","args":[],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"@buffer.map!(size) do |e|\n yield e\nend\nself\n"}},{"id":"map_with_index(&block)-instance-method","html_id":"map_with_index(&block)-instance-method","name":"map_with_index","doc":"Optimized version of `Enumerable#map_with_index`.","summary":"

Optimized version of Enumerable#map_with_index.

","abstract":false,"args":[],"args_string":"(&block)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L406","def":{"name":"map_with_index","args":[],"double_splat":null,"splat_index":null,"yields":2,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.new(size) do |i|\n yield @buffer[i], i\nend"}},{"id":"map_with_index!(&block)-instance-method","html_id":"map_with_index!(&block)-instance-method","name":"map_with_index!","doc":"Like `map_with_index`, but mutates `self` instead of allocating a new object.","summary":"

Like #map_with_index, but mutates self instead of allocating a new object.

","abstract":false,"args":[],"args_string":"(&block)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L411","def":{"name":"map_with_index!","args":[],"double_splat":null,"splat_index":null,"yields":2,"block_arg":null,"return_type":"","visibility":"Public","body":"to_unsafe.map_with_index!(size) do |e, i|\n yield e, i\nend\nself\n"}},{"id":"max-instance-method","html_id":"max-instance-method","name":"max","doc":"Returns the (absolute) largest element in this vector.","summary":"

Returns the (absolute) largest element in this vector.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L589","def":{"name":"max","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"reduce do |acc, i|\n i.abs > acc.abs ? i : acc\nend"}},{"id":"max_index-instance-method","html_id":"max_index-instance-method","name":"max_index","doc":"Gets the index of the largest element in this vector.","summary":"

Gets the index of the largest element in this vector.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L594","def":{"name":"max_index","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"idx = 0\neach_with_index do |e, i|\n idx = e.abs > self[idx].abs ? i : idx\nend\nidx\n"}},{"id":"multiply(value)-instance-method","html_id":"multiply(value)-instance-method","name":"multiply","doc":"When the input is a number, this returns the result of multiplying\nit to all vector elements. When it's a vector, the vectors\nwill be element-wise multiplied.","summary":"

When the input is a number, this returns the result of multiplying it to all vector elements.

","abstract":false,"args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(value)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L502","def":{"name":"multiply","args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"run_binary_op(value) do |a, b|\n a * b\nend"}},{"id":"parallel_to?(vector)-instance-method","html_id":"parallel_to?(vector)-instance-method","name":"parallel_to?","doc":"Returns whether the vectors are parallel to each other.","summary":"

Returns whether the vectors are parallel to each other.

","abstract":false,"args":[{"name":"vector","doc":null,"default_value":"","external_name":"vector","restriction":""}],"args_string":"(vector)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L469","def":{"name":"parallel_to?","args":[{"name":"vector","doc":null,"default_value":"","external_name":"vector","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"angle = angle_from(vector)\nangle <= Apatite.precision\n"}},{"id":"perpendicular_to?(vector)-instance-method","html_id":"perpendicular_to?(vector)-instance-method","name":"perpendicular_to?","doc":"Returns whether the vectors are perpendicular to each other.","summary":"

Returns whether the vectors are perpendicular to each other.

","abstract":false,"args":[{"name":"vector","doc":null,"default_value":"","external_name":"vector","restriction":""}],"args_string":"(vector)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L481","def":{"name":"perpendicular_to?","args":[{"name":"vector","doc":null,"default_value":"","external_name":"vector","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"(dot(vector)).abs <= Apatite.precision"}},{"id":"pretty_print(pp):Nil-instance-method","html_id":"pretty_print(pp):Nil-instance-method","name":"pretty_print","doc":null,"summary":null,"abstract":false,"args":[{"name":"pp","doc":null,"default_value":"","external_name":"pp","restriction":""}],"args_string":"(pp) : Nil","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L754","def":{"name":"pretty_print","args":[{"name":"pp","doc":null,"default_value":"","external_name":"pp","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Nil","visibility":"Public","body":"pp.list(\"Vector{\", self, \"}\")"}},{"id":"product-instance-method","html_id":"product-instance-method","name":"product","doc":"Get the product of all elements in this vector.","summary":"

Get the product of all elements in this vector.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L567","def":{"name":"product","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"reduce do |acc, v|\n acc = acc * v\nend"}},{"id":"push(*values:Float64)-instance-method","html_id":"push(*values:Float64)-instance-method","name":"push","doc":null,"summary":null,"abstract":false,"args":[{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":"Float64"}],"args_string":"(*values : Float64)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L665","def":{"name":"push","args":[{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":"Float64"}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"new_size = @size + values.size\nif new_size > @capacity\n resize_to_capacity(Math.pw2ceil(new_size))\nend\nvalues.each_with_index do |value, i|\n @buffer[@size + i] = value\nend\n@size = new_size\nself\n"}},{"id":"push(value:Float64)-instance-method","html_id":"push(value:Float64)-instance-method","name":"push","doc":null,"summary":null,"abstract":false,"args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":"Float64"}],"args_string":"(value : Float64)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L658","def":{"name":"push","args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":"Float64"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"check_needs_resize\n@buffer[@size] = value\n@size = @size + 1\nself\n"}},{"id":"reflection_in(object)-instance-method","html_id":"reflection_in(object)-instance-method","name":"reflection_in","doc":"Returns the result of reflecting the point in the given `object`\n(point, line, or plane).","summary":"

Returns the result of reflecting the point in the given object (point, line, or plane).

","abstract":false,"args":[{"name":"object","doc":null,"default_value":"","external_name":"object","restriction":""}],"args_string":"(object)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L684","def":{"name":"reflection_in","args":[{"name":"object","doc":null,"default_value":"","external_name":"object","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if object.is_a?(Plane) || object.is_a?(Line)\n p = @elements.dup\n c = (object.point_closest_to(p)).elements\n return Vector.create([C[0] + (C[0] - P[0]), C[1] + (C[1] - P[1]), C[2] + (C[2] - (P[2] || 0))])\nend\nq = object.is_a?(Vector) ? object.elements : object\nif @elements.size == q.size\nelse\n return nil\nend\nmap_with_index do |x, i|\n q[i - 1] + (q[i - 1] - x)\nend\n"}},{"id":"rotate(t,object)-instance-method","html_id":"rotate(t,object)-instance-method","name":"rotate","doc":"Rotates the vector about the given `object`. The object should\nbe a point if the vector is 2D, and a line if it is 3D. Be\ncareful with line directions!","summary":"

Rotates the vector about the given object.

","abstract":false,"args":[{"name":"t","doc":null,"default_value":"","external_name":"t","restriction":""},{"name":"object","doc":null,"default_value":"","external_name":"object","restriction":""}],"args_string":"(t, object)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L678","def":{"name":"rotate","args":[{"name":"t","doc":null,"default_value":"","external_name":"t","restriction":""},{"name":"object","doc":null,"default_value":"","external_name":"object","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":""}},{"id":"round-instance-method","html_id":"round-instance-method","name":"round","doc":"Gets the result of rounding the elements of the vector.","summary":"

Gets the result of rounding the elements of the vector.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L612","def":{"name":"round","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"map do |x|\n x.round\nend"}},{"id":"set_elements(elements)-instance-method","html_id":"set_elements(elements)-instance-method","name":"set_elements","doc":null,"summary":null,"abstract":false,"args":[{"name":"elements","doc":null,"default_value":"","external_name":"elements","restriction":""}],"args_string":"(elements)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L726","def":{"name":"set_elements","args":[{"name":"elements","doc":null,"default_value":"","external_name":"elements","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@elements = elements.is_a?(Vector) ? elements.elements : elements\nself\n"}},{"id":"sigmoid-instance-method","html_id":"sigmoid-instance-method","name":"sigmoid","doc":"Sums the numbers in the vector and returns a sigmoid value\nacross the whole vector.","summary":"

Sums the numbers in the vector and returns a sigmoid value across the whole vector.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L707","def":{"name":"sigmoid","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"LinearAlgebra.sigmoid(sum)"}},{"id":"size:Int32-instance-method","html_id":"size:Int32-instance-method","name":"size","doc":"Returns the number of elements in the vector","summary":"

Returns the number of elements in the vector

","abstract":false,"args":[],"args_string":" : Int32","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L24","def":{"name":"size","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Int32","visibility":"Public","body":"@size"}},{"id":"snap_to(value)-instance-method","html_id":"snap_to(value)-instance-method","name":"snap_to","doc":"Returns a copy of the vector with elements set to `value` if\nthey differ from it by less than `Apetite.precision`","summary":"

Returns a copy of the vector with elements set to value if they differ from it by less than Apetite.precision

","abstract":false,"args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(value)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L623","def":{"name":"snap_to","args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"map do |y|\n (y - x).abs <= Apetite.precision ? value : y\nend"}},{"id":"subtract(value)-instance-method","html_id":"subtract(value)-instance-method","name":"subtract","doc":"When the input is a number, this returns the result of subtracting\nit to all vector elements. When it's a vector, the vectors\nwill be subtracted.","summary":"

When the input is a number, this returns the result of subtracting it to all vector elements.

","abstract":false,"args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(value)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L495","def":{"name":"subtract","args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"run_binary_op(value) do |a, b|\n a - b\nend"}},{"id":"sum-instance-method","html_id":"sum-instance-method","name":"sum","doc":"Returns the sum of all elements in the vector.","summary":"

Returns the sum of all elements in the vector.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L507","def":{"name":"sum","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"reduce(0) do |acc, i|\n acc + i\nend"}},{"id":"to_3d-instance-method","html_id":"to_3d-instance-method","name":"to_3d","doc":"Utility to make sure vectors are 3D. If they are 2D, a zero\nz-component is added.","summary":"

Utility to make sure vectors are 3D.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L713","def":{"name":"to_3d","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"v = dup\ncase v.elements.size\nwhen 3\n break\nwhen 2\n v.elements.push(0)\nelse\n return nil\nend\nreturn v\n"}},{"id":"to_a-instance-method","html_id":"to_a-instance-method","name":"to_a","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L744","def":{"name":"to_a","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Array(Float64).new(size) do |i|\n self[i]\nend"}},{"id":"to_diagonal_matrix-instance-method","html_id":"to_diagonal_matrix-instance-method","name":"to_diagonal_matrix","doc":"Returns a diagonal `Matrix` with the vectors elements as its\ndiagonal elements.","summary":"

Returns a diagonal Matrix with the vectors elements as its diagonal elements.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L607","def":{"name":"to_diagonal_matrix","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix::Diagonal.new(elements)"}},{"id":"to_s(io)-instance-method","html_id":"to_s(io)-instance-method","name":"to_s","doc":null,"summary":null,"abstract":false,"args":[{"name":"io","doc":null,"default_value":"","external_name":"io","restriction":""}],"args_string":"(io)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L748","def":{"name":"to_s","args":[{"name":"io","doc":null,"default_value":"","external_name":"io","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"io << \"{\"\njoin(\", \", io, &.inspect(io))\nio << \"}\"\n"}},{"id":"to_unit_vector-instance-method","html_id":"to_unit_vector-instance-method","name":"to_unit_vector","doc":"Returns a new vector created by normalizing this one\nto have a magnitude of `1`. If the vector is a zero\nvector, it will not be modified.","summary":"

Returns a new vector created by normalizing this one to have a magnitude of 1.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L433","def":{"name":"to_unit_vector","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"r = magnitude\nr == 0 ? dup : map do |x|\n x.to_f64 / r\nend\n"}},{"id":"to_unsafe:Pointer(Float64)-instance-method","html_id":"to_unsafe:Pointer(Float64)-instance-method","name":"to_unsafe","doc":"Returns a pointer to the internal buffer where `self`'s elements are stored.\n\nThis method is **unsafe** because it returns a pointer, and the pointed might eventually\nnot be that of `self` if the array grows and its internal buffer is reallocated.\n\n```\nvec = Vector{1.0, 2.0, 3.0}\nvec.to_unsafe[0] # => 1.0\n```","summary":"

Returns a pointer to the internal buffer where self's elements are stored.

","abstract":false,"args":[],"args_string":" : Pointer(Float64)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L772","def":{"name":"to_unsafe","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Pointer(Float64)","visibility":"Public","body":"@buffer"}},{"id":"top(n)-instance-method","html_id":"top(n)-instance-method","name":"top","doc":"Returns a vector containing only the first `n` elements.","summary":"

Returns a vector containing only the first n elements.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L548","def":{"name":"top","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"elements = [] of Float64\neach_with_index do |e, i|\n if i < n\n elements << e\n end\nend\nVector.create(elements)\n"}},{"id":"transpose-instance-method","html_id":"transpose-instance-method","name":"transpose","doc":"Transpose this vector into a 1xn `Matrix`","summary":"

Transpose this vector into a 1xn Matrix

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L617","def":{"name":"transpose","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.col_vector(self)"}},{"id":"unsafe_fetch(index:Int)-instance-method","html_id":"unsafe_fetch(index:Int)-instance-method","name":"unsafe_fetch","doc":null,"summary":null,"abstract":false,"args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"}],"args_string":"(index : Int)","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L759","def":{"name":"unsafe_fetch","args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@buffer[index]"}},{"id":"zero?-instance-method","html_id":"zero?-instance-method","name":"zero?","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/linear_algebra/vector.cr#L788","def":{"name":"zero?","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"all?(&.zero?)"}}],"macros":[],"types":[]}]}]},{"html_id":"github.com/watzon/apatite/Array","path":"Array.html","kind":"class","full_name":"Array(T)","name":"Array","abstract":false,"superclass":{"html_id":"github.com/watzon/apatite/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"github.com/watzon/apatite/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"github.com/watzon/apatite/Indexable","kind":"module","full_name":"Indexable","name":"Indexable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Iterable","kind":"module","full_name":"Iterable","name":"Iterable"},{"html_id":"github.com/watzon/apatite/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"github.com/watzon/apatite/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"apatite/core_ext/array.cr","line_number":1,"url":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/core_ext/array.cr"}],"repository_name":"github.com/watzon/apatite","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[{"html_id":"github.com/watzon/apatite/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"github.com/watzon/apatite/Indexable","kind":"module","full_name":"Indexable","name":"Indexable"}],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":null,"doc":"An `Array` is an ordered, integer-indexed collection of objects of type T.\n\nArray indexing starts at 0. A negative index is assumed to be\nrelative to the end of the array: -1 indicates the last element,\n-2 is the next to last element, and so on.\n\nAn `Array` can be created using the usual `new` method (several are provided), or with an array literal:\n\n```\nArray(Int32).new # => []\n[1, 2, 3] # Array(Int32)\n[1, \"hello\", 'x'] # Array(Int32 | String | Char)\n```\n\nAn `Array` can have mixed types, meaning T will be a union of types, but these are determined\nwhen the array is created, either by specifying T or by using an array literal. In the latter\ncase, T will be set to the union of the array literal elements' types.\n\nWhen creating an empty array you must always specify T:\n\n```\n[] of Int32 # same as Array(Int32)\n[] # syntax error\n```\n\nAn `Array` is implemented using an internal buffer of some capacity\nand is reallocated when elements are pushed to it when more capacity\nis needed. This is normally known as a [dynamic array](http://en.wikipedia.org/wiki/Dynamic_array).\n\nYou can use a special array literal syntax with other types too, as long as they define an argless\n`new` method and a `<<` method. `Set` is one such type:\n\n```\nset = Set{1, 2, 3} # => Set{1, 2, 3}\nset.class # => Set(Int32)\n```\n\nThe above is the same as this:\n\n```\nset = Set(typeof(1, 2, 3)).new\nset << 1\nset << 2\nset << 3\n```","summary":"

An Array is an ordered, integer-indexed collection of objects of type T.

","class_methods":[],"constructors":[],"instance_methods":[{"id":"all?-instance-method","html_id":"all?-instance-method","name":"all?","doc":"Tests whether all elements evaluate to true","summary":"

Tests whether all elements evaluate to true

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/core_ext/array.cr#L3","def":{"name":"all?","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"each do |i|\n if (!(!i)) == false\n return false\n end\nend\ntrue\n"}},{"id":"any?-instance-method","html_id":"any?-instance-method","name":"any?","doc":"Tests whether any of the elements evaluate to true","summary":"

Tests whether any of the elements evaluate to true

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/core_ext/array.cr#L11","def":{"name":"any?","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"each do |i|\n if (!(!i)) == true\n return true\n end\nend\nfalse\n"}},{"id":"shape-instance-method","html_id":"shape-instance-method","name":"shape","doc":"Get the array's dimensions","summary":"

Get the array's dimensions

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/core_ext/array.cr#L19","def":{"name":"shape","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"max = max_by do |i|\n i.is_a?(Array) ? i.size : i\nend\nmax.is_a?(Array) ? [size, max.size] : [max]\n"}},{"id":"to_vec-instance-method","html_id":"to_vec-instance-method","name":"to_vec","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/bb0f2c43324c0d6ab61bd78a63170c4d2e671d2f/src/apatite/core_ext/array.cr#L24","def":{"name":"to_vec","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Apatite::Vector.create(self)"}}],"macros":[],"types":[]}]}}) \ No newline at end of file +crystal_doc_search_index_callback({"repository_name":"github.com/watzon/apatite","body":"# Apatite\n\nApatite is meant to be a collecion of mathmatical and scientific computing algorithms for the Crystal programming language. I don't expect it to ever reach the level of completeness as numpy, but hopefully it can save some people the trouble of implementing these methods on their own.\n\n## Installation\n\n1. Add the dependency to your `shard.yml`:\n\n ```yaml\n dependencies:\n apatite:\n github: watzon/apatite\n ```\n\n2. Run `shards install`\n\n## Usage\n\n```crystal\nrequire \"apatite\"\n```\n\nTODO: Write usage instructions here, but first write the library...\n\n## Roadmap\n\n- [ ] Apetite\n\t- [ ] Vector Math\n\t\t- [ ] Matrix\n\t\t- [ ] NDArray\n\t\t- [x] Vector\n\t\t- [ ] Line\n\t\t- [ ] Plane\n\t\t- [ ] Polygon\n\t\t- [ ] LinkedList\n\t\n\n\n## Contributing\n\n1. Fork it ()\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n## Contributors\n\n- [Chris Watson](https://github.com/watzon) - creator and maintainer","program":{"html_id":"github.com/watzon/apatite/toplevel","path":"toplevel.html","kind":"module","full_name":"Top Level Namespace","name":"Top Level Namespace","abstract":false,"superclass":null,"ancestors":[],"locations":[],"repository_name":"github.com/watzon/apatite","program":true,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":null,"doc":null,"summary":null,"class_methods":[],"constructors":[],"instance_methods":[],"macros":[],"types":[{"html_id":"github.com/watzon/apatite/Apatite","path":"Apatite.html","kind":"module","full_name":"Apatite","name":"Apatite","abstract":false,"superclass":null,"ancestors":[{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra","kind":"module","full_name":"Apatite::LinearAlgebra","name":"LinearAlgebra"}],"locations":[{"filename":"apatite/linear_algebra/ndarray.cr","line_number":1,"url":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/ndarray.cr"},{"filename":"apatite/linear_algebra.cr","line_number":5,"url":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra.cr"},{"filename":"apatite.cr","line_number":10,"url":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite.cr"},{"filename":"apatite/version.cr","line_number":1,"url":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/version.cr"}],"repository_name":"github.com/watzon/apatite","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[{"id":"I","name":"I","value":"Vector::I","doc":"Cartesian unit vector I\n\n`Vector{1.0, 0.0, 0.0}`","summary":"

Cartesian unit vector I

"},{"id":"J","name":"J","value":"Vector::J","doc":"Cartesian unit vector J\n\n`Vector{0.0, 1.0, 0.0}`","summary":"

Cartesian unit vector J

"},{"id":"K","name":"K","value":"Vector::K","doc":"Cartesian unit vector K\n\n`Vector{0.0, 0.0, 1.0}`","summary":"

Cartesian unit vector K

"},{"id":"VERSION","name":"VERSION","value":"\"0.1.0\"","doc":null,"summary":null}],"included_modules":[{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra","kind":"module","full_name":"Apatite::LinearAlgebra","name":"LinearAlgebra"}],"extended_modules":[{"html_id":"github.com/watzon/apatite/Apatite","kind":"module","full_name":"Apatite","name":"Apatite"}],"subclasses":[],"including_types":[],"namespace":null,"doc":"Apatite is a fundimental package for scientific computing in Crystal. If that\nsounds like a modified version of the first line from the NumPy homepage,\nthat's because it is. Apatite has (ok, will have) all of the goodness\nof NumPy sitting atop the blazing speed and beautiful syntax\nof Crystal.","summary":"

Apatite is a fundimental package for scientific computing in Crystal.

","class_methods":[],"constructors":[],"instance_methods":[{"id":"as_vector(input:Indexable)-instance-method","html_id":"as_vector(input:Indexable)-instance-method","name":"as_vector","doc":"Creates a new vector from the given `input`. Input can be any\n`Indexable` type.","summary":"

Creates a new vector from the given input.

","abstract":false,"args":[{"name":"input","doc":null,"default_value":"","external_name":"input","restriction":"Indexable"}],"args_string":"(input : Indexable)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite.cr#L61","def":{"name":"as_vector","args":[{"name":"input","doc":null,"default_value":"","external_name":"input","restriction":"Indexable"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.create(input)"}},{"id":"basis(size,index)-instance-method","html_id":"basis(size,index)-instance-method","name":"basis","doc":"Creates a standard basis-n vector of the given `size` and `index`.","summary":"

Creates a standard basis-n vector of the given size and index.

","abstract":false,"args":[{"name":"size","doc":null,"default_value":"","external_name":"size","restriction":""},{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":""}],"args_string":"(size, index)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite.cr#L66","def":{"name":"basis","args":[{"name":"size","doc":null,"default_value":"","external_name":"size","restriction":""},{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.basis(size, index)"}},{"id":"diagonal(values)-instance-method","html_id":"diagonal(values)-instance-method","name":"diagonal","doc":"Creates a matrix where the diagonal elements are composed of `values`.","summary":"

Creates a matrix where the diagonal elements are composed of values.

","abstract":false,"args":[{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":""}],"args_string":"(values)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite.cr#L89","def":{"name":"diagonal","args":[{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.diagonal(values)"}},{"id":"empty-instance-method","html_id":"empty-instance-method","name":"empty","doc":"Returns a new empty `Vector`","summary":"

Returns a new empty Vector

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite.cr#L34","def":{"name":"empty","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.new"}},{"id":"empty_matrix(row_count=0,column_count=0)-instance-method","html_id":"empty_matrix(row_count=0,column_count=0)-instance-method","name":"empty_matrix","doc":"Creates a new empty matrix with the given `row_count` and\n`column_count`. At lease one of `row_count` or\n`column_count` must be zero.","summary":"

Creates a new empty matrix with the given row_count and column_count.

","abstract":false,"args":[{"name":"row_count","doc":null,"default_value":"0","external_name":"row_count","restriction":""},{"name":"column_count","doc":null,"default_value":"0","external_name":"column_count","restriction":""}],"args_string":"(row_count = 0, column_count = 0)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite.cr#L84","def":{"name":"empty_matrix","args":[{"name":"row_count","doc":null,"default_value":"0","external_name":"row_count","restriction":""},{"name":"column_count","doc":null,"default_value":"0","external_name":"column_count","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.new(rows, column_count)"}},{"id":"eye(n)-instance-method","html_id":"eye(n)-instance-method","name":"eye","doc":"Creates a new diagonal matrix of size `n` with ones in the diagonal\nand zeros elsewhere.","summary":"

Creates a new diagonal matrix of size n with ones in the diagonal and zeros elsewhere.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite.cr#L95","def":{"name":"eye","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.eye(n)"}},{"id":"full(n,i)-instance-method","html_id":"full(n,i)-instance-method","name":"full","doc":"Returns a new vector of size `n` filled with `i`","summary":"

Returns a new vector of size n filled with i

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""},{"name":"i","doc":null,"default_value":"","external_name":"i","restriction":""}],"args_string":"(n, i)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite.cr#L49","def":{"name":"full","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""},{"name":"i","doc":null,"default_value":"","external_name":"i","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.new(n, i)"}},{"id":"identity(n)-instance-method","html_id":"identity(n)-instance-method","name":"identity","doc":"Creates a `n x n` identity matrix.","summary":"

Creates a n x n identity matrix.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite.cr#L100","def":{"name":"identity","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.identity(n)"}},{"id":"ones(n)-instance-method","html_id":"ones(n)-instance-method","name":"ones","doc":"Returns a new vector filled with `n` ones.","summary":"

Returns a new vector filled with n ones.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite.cr#L39","def":{"name":"ones","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.ones(n)"}},{"id":"random(n,range=nil)-instance-method","html_id":"random(n,range=nil)-instance-method","name":"random","doc":"Creates a new vector of size `n` filled with random numbers. A `range`\ncan optionally be passed in if you want to limit the random numbers\nto a given range.","summary":"

Creates a new vector of size n filled with random numbers.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""},{"name":"range","doc":null,"default_value":"nil","external_name":"range","restriction":""}],"args_string":"(n, range = nil)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite.cr#L73","def":{"name":"random","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""},{"name":"range","doc":null,"default_value":"nil","external_name":"range","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.random(n, range)"}},{"id":"row_vector(row)-instance-method","html_id":"row_vector(row)-instance-method","name":"row_vector","doc":"Creates a single-row matrix where the values of that row are as given in `row`.","summary":"

Creates a single-row matrix where the values of that row are as given in row.

","abstract":false,"args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":""}],"args_string":"(row)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite.cr#L105","def":{"name":"row_vector","args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.row_vector(row)"}},{"id":"scalar(n,value)-instance-method","html_id":"scalar(n,value)-instance-method","name":"scalar","doc":"Creates an `n` by `n` diagonal matrix where each diagonal element is value.","summary":"

Creates an n by n diagonal matrix where each diagonal element is value.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(n, value)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite.cr#L110","def":{"name":"scalar","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.scalar(n, value)"}},{"id":"vector(n,&block)-instance-method","html_id":"vector(n,&block)-instance-method","name":"vector","doc":"Creates a new vector of size `n`, and invokes the block once\nfor each index of `self`, assigning the block's value in that index.","summary":"

Creates a new vector of size n, and invokes the block once for each index of self, assigning the block's value in that index.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n, &block)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite.cr#L55","def":{"name":"vector","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.new(n) do |i|\n yield i\nend"}},{"id":"zeros(n)-instance-method","html_id":"zeros(n)-instance-method","name":"zeros","doc":"Returns a new vector filled with `n` zeros.","summary":"

Returns a new vector filled with n zeros.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite.cr#L44","def":{"name":"zeros","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.zeros(n)"}}],"macros":[],"types":[{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra","path":"Apatite/LinearAlgebra.html","kind":"module","full_name":"Apatite::LinearAlgebra","name":"LinearAlgebra","abstract":false,"superclass":null,"ancestors":[],"locations":[{"filename":"apatite/linear_algebra/ndarray.cr","line_number":1,"url":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/ndarray.cr"},{"filename":"apatite/linear_algebra/vector.cr","line_number":1,"url":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr"},{"filename":"apatite/linear_algebra/matrix.cr","line_number":3,"url":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr"},{"filename":"apatite/linear_algebra.cr","line_number":6,"url":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra.cr"}],"repository_name":"github.com/watzon/apatite","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[],"extended_modules":[{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra","kind":"module","full_name":"Apatite::LinearAlgebra","name":"LinearAlgebra"}],"subclasses":[],"including_types":[{"html_id":"github.com/watzon/apatite/Apatite","kind":"module","full_name":"Apatite","name":"Apatite"}],"namespace":{"html_id":"github.com/watzon/apatite/Apatite","kind":"module","full_name":"Apatite","name":"Apatite"},"doc":null,"summary":null,"class_methods":[],"constructors":[],"instance_methods":[{"id":"sigmoid(input:Number)-instance-method","html_id":"sigmoid(input:Number)-instance-method","name":"sigmoid","doc":"Calculates the sigmoid curve for a numeric input.\n\n`f(x) = 1/(1 + e^-x)`\n\nSee also: [Sigmoid function (WikiWand)](https://www.wikiwand.com/en/Sigmoid_function)","summary":"

Calculates the sigmoid curve for a numeric input.

","abstract":false,"args":[{"name":"input","doc":null,"default_value":"","external_name":"input","restriction":"Number"}],"args_string":"(input : Number)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra.cr#L14","def":{"name":"sigmoid","args":[{"name":"input","doc":null,"default_value":"","external_name":"input","restriction":"Number"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"num = input.to_f64\n1 / (1 + (Math.exp(-num)))\n"}},{"id":"sigmoid_d(input:Number)-instance-method","html_id":"sigmoid_d(input:Number)-instance-method","name":"sigmoid_d","doc":"Calculates the derivative sigmoid curve for a numeric input.\n\n`f'(x) = f(x)(1 - f(x)),`","summary":"

Calculates the derivative sigmoid curve for a numeric input.

","abstract":false,"args":[{"name":"input","doc":null,"default_value":"","external_name":"input","restriction":"Number"}],"args_string":"(input : Number)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra.cr#L22","def":{"name":"sigmoid_d","args":[{"name":"input","doc":null,"default_value":"","external_name":"input","restriction":"Number"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"num = input.to_f64\nnum * (1 - num)\n"}}],"macros":[],"types":[{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra/Matrix","path":"Apatite/LinearAlgebra/Matrix.html","kind":"class","full_name":"Apatite::LinearAlgebra::Matrix","name":"Matrix","abstract":false,"superclass":{"html_id":"github.com/watzon/apatite/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"github.com/watzon/apatite/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"github.com/watzon/apatite/Indexable","kind":"module","full_name":"Indexable","name":"Indexable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Iterable","kind":"module","full_name":"Iterable","name":"Iterable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"github.com/watzon/apatite/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"apatite/linear_algebra/matrix.cr","line_number":4,"url":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr"}],"repository_name":"github.com/watzon/apatite","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[{"html_id":"github.com/watzon/apatite/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Indexable","kind":"module","full_name":"Indexable","name":"Indexable"}],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra","kind":"module","full_name":"Apatite::LinearAlgebra","name":"LinearAlgebra"},"doc":null,"summary":null,"class_methods":[{"id":"[](*rows)-class-method","html_id":"[](*rows)-class-method","name":"[]","doc":"Creates a matrix where each argument is a row.","summary":"

Creates a matrix where each argument is a row.

","abstract":false,"args":[{"name":"rows","doc":null,"default_value":"","external_name":"rows","restriction":""}],"args_string":"(*rows)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L22","def":{"name":"[]","args":[{"name":"rows","doc":null,"default_value":"","external_name":"rows","restriction":""}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"rows(rows)"}},{"id":"build(row_count,column_count=row_count,&block)-class-method","html_id":"build(row_count,column_count=row_count,&block)-class-method","name":"build","doc":"Creates a matrix of size `row_count x column_count`. It fills the values by calling\nthe given block, passing the current row and column.","summary":"

Creates a matrix of size row_count x column_count.

","abstract":false,"args":[{"name":"row_count","doc":null,"default_value":"","external_name":"row_count","restriction":""},{"name":"column_count","doc":null,"default_value":"row_count","external_name":"column_count","restriction":""}],"args_string":"(row_count, column_count = row_count, &block)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L28","def":{"name":"build","args":[{"name":"row_count","doc":null,"default_value":"","external_name":"row_count","restriction":""},{"name":"column_count","doc":null,"default_value":"row_count","external_name":"column_count","restriction":""}],"double_splat":null,"splat_index":null,"yields":2,"block_arg":null,"return_type":"","visibility":"Public","body":"if row_count < 0 || column_count < 0\n raise(ArgumentError.new)\nend\nrows = Array.new(row_count) do |i|\n Vector.new(column_count) do |j|\n yield i, j\n end\nend\nMatrix.new(rows, column_count)\n"}},{"id":"col_vector(column)-class-method","html_id":"col_vector(column)-class-method","name":"col_vector","doc":"Creates a single-column matrix where the values of that column are as given in column.","summary":"

Creates a single-column matrix where the values of that column are as given in column.

","abstract":false,"args":[{"name":"column","doc":null,"default_value":"","external_name":"column","restriction":""}],"args_string":"(column)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L39","def":{"name":"col_vector","args":[{"name":"column","doc":null,"default_value":"","external_name":"column","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.new([column].transpose, 1)"}},{"id":"columns(columns)-class-method","html_id":"columns(columns)-class-method","name":"columns","doc":"Creates a matrix using `columns` as an array of column vectors.","summary":"

Creates a matrix using .columns as an array of column vectors.

","abstract":false,"args":[{"name":"columns","doc":null,"default_value":"","external_name":"columns","restriction":""}],"args_string":"(columns)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L44","def":{"name":"columns","args":[{"name":"columns","doc":null,"default_value":"","external_name":"columns","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"(rows(columns)).transpose"}},{"id":"diagonal(values)-class-method","html_id":"diagonal(values)-class-method","name":"diagonal","doc":"Creates a matrix where the diagonal elements are composed of `values`.","summary":"

Creates a matrix where the diagonal elements are composed of values.

","abstract":false,"args":[{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":""}],"args_string":"(values)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L70","def":{"name":"diagonal","args":[{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"size = values.size\nif size == 0\n return Matrix.empty\nend\nrows = Array.new(size) do |j|\n row = Array.new(size, 0)\n row[j] = values[j]\n row\nend\nnew(rows)\n"}},{"id":"diagonal(*values)-class-method","html_id":"diagonal(*values)-class-method","name":"diagonal","doc":"Creates a matrix where the diagonal elements are composed of `values`.","summary":"

Creates a matrix where the diagonal elements are composed of values.

","abstract":false,"args":[{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":""}],"args_string":"(*values)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L84","def":{"name":"diagonal","args":[{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":""}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.diagonal(values)"}},{"id":"empty(row_count=0,column_count=0)-class-method","html_id":"empty(row_count=0,column_count=0)-class-method","name":"empty","doc":"Creates a empty matrix of `row_count x column_count`. At least one of\n`row_count` or `column_count` must be 0.","summary":"

Creates a empty matrix of row_count x column_count.

","abstract":false,"args":[{"name":"row_count","doc":null,"default_value":"0","external_name":"row_count","restriction":""},{"name":"column_count","doc":null,"default_value":"0","external_name":"column_count","restriction":""}],"args_string":"(row_count = 0, column_count = 0)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L90","def":{"name":"empty","args":[{"name":"row_count","doc":null,"default_value":"0","external_name":"row_count","restriction":""},{"name":"column_count","doc":null,"default_value":"0","external_name":"column_count","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if (column_count != 0) && (row_count != 0)\n raise(ArgumentError.new(\"One size must be 0\"))\nend\nif column_count < 0 || row_count < 0\n raise(ArgumentError.new(\"Negative size\"))\nend\nMatrix.new(([] of Vector) * row_count, column_count)\n"}},{"id":"eye(n)-class-method","html_id":"eye(n)-class-method","name":"eye","doc":"Creates a new diagonal matrix of size `n` with ones in the diagonal\nand zeros elsewhere.","summary":"

Creates a new diagonal matrix of size n with ones in the diagonal and zeros elsewhere.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L98","def":{"name":"eye","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.diagonal([1] * n)"}},{"id":"hstack(x,*matrices)-class-method","html_id":"hstack(x,*matrices)-class-method","name":"hstack","doc":"TODO","summary":"

TODO

","abstract":false,"args":[{"name":"x","doc":null,"default_value":"","external_name":"x","restriction":""},{"name":"matrices","doc":null,"default_value":"","external_name":"matrices","restriction":""}],"args_string":"(x, *matrices)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L103","def":{"name":"hstack","args":[{"name":"x","doc":null,"default_value":"","external_name":"x","restriction":""},{"name":"matrices","doc":null,"default_value":"","external_name":"matrices","restriction":""}],"double_splat":null,"splat_index":1,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":""}},{"id":"identity(n)-class-method","html_id":"identity(n)-class-method","name":"identity","doc":"Creates a `n x n` identity matrix.","summary":"

Creates a n x n identity matrix.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L107","def":{"name":"identity","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"scalar(n, 1)"}},{"id":"row_vector(row)-class-method","html_id":"row_vector(row)-class-method","name":"row_vector","doc":"Creates a single-row matrix where the values of that row are as given in `row`.","summary":"

Creates a single-row matrix where the values of that row are as given in #row.

","abstract":false,"args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":""}],"args_string":"(row)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L112","def":{"name":"row_vector","args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.new([row], 0)"}},{"id":"rows(rows)-class-method","html_id":"rows(rows)-class-method","name":"rows","doc":"Creates a matrix where rows is an array of arrays, each of which is a row of the matrix.","summary":"

Creates a matrix where rows is an array of arrays, each of which is a row of the matrix.

","abstract":false,"args":[{"name":"rows","doc":null,"default_value":"","external_name":"rows","restriction":""}],"args_string":"(rows)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L117","def":{"name":"rows","args":[{"name":"rows","doc":null,"default_value":"","external_name":"rows","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"size = rows[0]? ? rows[0].size : 0\nrows.each do |row|\n if row.size == size\n else\n raise(\"Dimension mismatch: row size differs (#{row.size} should be #{size})\")\n end\nend\nMatrix.new(rows, size)\n"}},{"id":"scalar(n,value)-class-method","html_id":"scalar(n,value)-class-method","name":"scalar","doc":"Creates an `n` by `n` diagonal matrix where each diagonal element is value.","summary":"

Creates an n by n diagonal matrix where each diagonal element is value.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(n, value)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L126","def":{"name":"scalar","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.diagonal(Array.new(n, value))"}},{"id":"vstack(x,y)-class-method","html_id":"vstack(x,y)-class-method","name":"vstack","doc":"TODO","summary":"

TODO

","abstract":false,"args":[{"name":"x","doc":null,"default_value":"","external_name":"x","restriction":""},{"name":"y","doc":null,"default_value":"","external_name":"y","restriction":""}],"args_string":"(x, y)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L131","def":{"name":"vstack","args":[{"name":"x","doc":null,"default_value":"","external_name":"x","restriction":""},{"name":"y","doc":null,"default_value":"","external_name":"y","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":""}},{"id":"zero(row_count,column_count=row_count)-class-method","html_id":"zero(row_count,column_count=row_count)-class-method","name":"zero","doc":"Creates a zero matrix.","summary":"

Creates a zero matrix.

","abstract":false,"args":[{"name":"row_count","doc":null,"default_value":"","external_name":"row_count","restriction":""},{"name":"column_count","doc":null,"default_value":"row_count","external_name":"column_count","restriction":""}],"args_string":"(row_count, column_count = row_count)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L135","def":{"name":"zero","args":[{"name":"row_count","doc":null,"default_value":"","external_name":"row_count","restriction":""},{"name":"column_count","doc":null,"default_value":"row_count","external_name":"column_count","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"rows = Array.new(row_count) do\n Vector.new(column_count)\nend\nMatrix.new(rows, column_count)\n"}}],"constructors":[{"id":"new(rows,column_count:Int32?=nil)-class-method","html_id":"new(rows,column_count:Int32?=nil)-class-method","name":"new","doc":null,"summary":null,"abstract":false,"args":[{"name":"rows","doc":null,"default_value":"","external_name":"rows","restriction":""},{"name":"column_count","doc":null,"default_value":"nil","external_name":"column_count","restriction":"Int32 | ::Nil"}],"args_string":"(rows, column_count : Int32? = nil)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L15","def":{"name":"new","args":[{"name":"rows","doc":null,"default_value":"","external_name":"rows","restriction":""},{"name":"column_count","doc":null,"default_value":"nil","external_name":"column_count","restriction":"Int32 | ::Nil"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"_ = allocate\n_.initialize(rows, column_count)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"id":"*(other:Matrix)-instance-method","html_id":"*(other:Matrix)-instance-method","name":"*","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"args_string":"(other : Matrix)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L140","def":{"name":"*","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if column_count != other.column_count\n raise(\"Dimension mismatch\")\nend\nrows = Array.new(row_count) do |i|\n Vector.new(other.column_count) do |j|\n (0...column_count).reduce(0.0) do |vij, k|\n vij + (self[i, k] * other[k, j])\n end\n end\nend\nreturn Matrix.new(rows, other.column_count)\n"}},{"id":"*(int:Int)-instance-method","html_id":"*(int:Int)-instance-method","name":"*","doc":null,"summary":null,"abstract":false,"args":[{"name":"int","doc":null,"default_value":"","external_name":"int","restriction":"Int"}],"args_string":"(int : Int)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L154","def":{"name":"*","args":[{"name":"int","doc":null,"default_value":"","external_name":"int","restriction":"Int"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"rows = self.rows.map do |row|\n row.map do |e|\n e * int\n end\nend\nMatrix.new(rows, column_count)\n"}},{"id":"*(ind:Indexable)-instance-method","html_id":"*(ind:Indexable)-instance-method","name":"*","doc":null,"summary":null,"abstract":false,"args":[{"name":"ind","doc":null,"default_value":"","external_name":"ind","restriction":"Indexable"}],"args_string":"(ind : Indexable)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L161","def":{"name":"*","args":[{"name":"ind","doc":null,"default_value":"","external_name":"ind","restriction":"Indexable"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"m = column_vector\nr = self * m\nr.column(0)\n"}},{"id":"**(int)-instance-method","html_id":"**(int)-instance-method","name":"**","doc":null,"summary":null,"abstract":false,"args":[{"name":"int","doc":null,"default_value":"","external_name":"int","restriction":""}],"args_string":"(int)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L167","def":{"name":"**","args":[{"name":"int","doc":null,"default_value":"","external_name":"int","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if int >= 1\nelse\n raise(\"Number can not the less than 1\")\nend\nmat = self\n(int - 1).times do\n mat = mat * self\nend\nmat\n"}},{"id":"+(other:Matrix)-instance-method","html_id":"+(other:Matrix)-instance-method","name":"+","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"args_string":"(other : Matrix)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L176","def":{"name":"+","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if column_count != other.column_count\n raise(\"Dimension mismatch\")\nend\nrows = Array.new(row_count) do |i|\n Vector.new(other.column_count) do |j|\n self[i, j] + other[i, j]\n end\nend\nreturn Matrix.new(rows, other.column_count)\n"}},{"id":"+(vec:Indexable)-instance-method","html_id":"+(vec:Indexable)-instance-method","name":"+","doc":null,"summary":null,"abstract":false,"args":[{"name":"vec","doc":null,"default_value":"","external_name":"vec","restriction":"Indexable"}],"args_string":"(vec : Indexable)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L188","def":{"name":"+","args":[{"name":"vec","doc":null,"default_value":"","external_name":"vec","restriction":"Indexable"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"vec = vec.is_a?(Vector) ? vec : Vector.create(vec)\nself + (column_vector(vec))\n"}},{"id":"-(vec:Indexable)-instance-method","html_id":"-(vec:Indexable)-instance-method","name":"-","doc":null,"summary":null,"abstract":false,"args":[{"name":"vec","doc":null,"default_value":"","external_name":"vec","restriction":"Indexable"}],"args_string":"(vec : Indexable)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L205","def":{"name":"-","args":[{"name":"vec","doc":null,"default_value":"","external_name":"vec","restriction":"Indexable"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"vec = vec.is_a?(Vector) ? vec : Vector.create(vec)\nself + (column_vector(vec))\n"}},{"id":"-(other:Matrix)-instance-method","html_id":"-(other:Matrix)-instance-method","name":"-","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"args_string":"(other : Matrix)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L193","def":{"name":"-","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if column_count != other.column_count\n raise(\"Dimension mismatch\")\nend\nrows = Array.new(row_count) do |i|\n Vector.new(other.column_count) do |j|\n self[i, j] - other[i, j]\n end\nend\nreturn Matrix.new(rows, other.column_count)\n"}},{"id":"/(other:Matrix)-instance-method","html_id":"/(other:Matrix)-instance-method","name":"/","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"args_string":"(other : Matrix)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L210","def":{"name":"/","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"self * other.inverse"}},{"id":"/(vec:Indexable)-instance-method","html_id":"/(vec:Indexable)-instance-method","name":"/","doc":null,"summary":null,"abstract":false,"args":[{"name":"vec","doc":null,"default_value":"","external_name":"vec","restriction":"Indexable"}],"args_string":"(vec : Indexable)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L214","def":{"name":"/","args":[{"name":"vec","doc":null,"default_value":"","external_name":"vec","restriction":"Indexable"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"rows = self.rows.map do |row|\n row.map do |e|\n e / other\n end\nend\nreturn new_matrix(rows, column_count)\n"}},{"id":"==(other:Matrix)-instance-method","html_id":"==(other:Matrix)-instance-method","name":"==","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"args_string":"(other : Matrix)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L221","def":{"name":"==","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Matrix"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if (Matrix === other) && (column_count == other.column_count)\nelse\n return false\nend\nrows == other.rows\n"}},{"id":"[](row:Int,col:Int)-instance-method","html_id":"[](row:Int,col:Int)-instance-method","name":"[]","doc":"Returns element `(row, col)` of the matrix. Throws error on index error.","summary":"

Returns element (row, col) of the matrix.

","abstract":false,"args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":"Int"},{"name":"col","doc":null,"default_value":"","external_name":"col","restriction":"Int"}],"args_string":"(row : Int, col : Int)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L228","def":{"name":"[]","args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":"Int"},{"name":"col","doc":null,"default_value":"","external_name":"col","restriction":"Int"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"self[row][col]"}},{"id":"[]?(row:Int,col:Int)-instance-method","html_id":"[]?(row:Int,col:Int)-instance-method","name":"[]?","doc":"Returns element `(row, col)` of the matrix, or nil if the index is not found.","summary":"

Returns element (row, col) of the matrix, or nil if the index is not found.

","abstract":false,"args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":"Int"},{"name":"col","doc":null,"default_value":"","external_name":"col","restriction":"Int"}],"args_string":"(row : Int, col : Int)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L233","def":{"name":"[]?","args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":"Int"},{"name":"col","doc":null,"default_value":"","external_name":"col","restriction":"Int"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"v = fetch(row) do\n nil\nend\nif v.nil?\nelse\n v[col]?\nend\n"}},{"id":"adjugate-instance-method","html_id":"adjugate-instance-method","name":"adjugate","doc":"Returns the adjugate of the matrix.","summary":"

Returns the adjugate of the matrix.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L239","def":{"name":"adjugate","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if square?\nelse\n raise(\"Dimention mismatch: `Matrix#adjugate` requires a square matrix.\")\nend\nMatrix.build(row_count, column_count) do |row, column|\n cofactor(column, row)\nend\n"}},{"id":"cofactor(row,column)-instance-method","html_id":"cofactor(row,column)-instance-method","name":"cofactor","doc":"Returns the (row, column) cofactor which is obtained by multiplying the first minor by (-1)**(row + column)","summary":"

Returns the (row, column) cofactor which is obtained by multiplying the first minor by (-1)**(row + column)

","abstract":false,"args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":""},{"name":"column","doc":null,"default_value":"","external_name":"column","restriction":""}],"args_string":"(row, column)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L247","def":{"name":"cofactor","args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":""},{"name":"column","doc":null,"default_value":"","external_name":"column","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if empty?\n raise(\"cofactor of empty matrix is not defined\")\nend\nif square?\nelse\n raise(\"Dimention mismatch: `Matrix#cofactor` requires a square matrix.\")\nend\ndet_of_minor = (first_minor(row, column)).determinant\ndet_of_minor * ((-1.0) ** (row + column))\n"}},{"id":"column(j,&block)-instance-method","html_id":"column(j,&block)-instance-method","name":"column","doc":"Iterates over the specified column in the matrix, returning the Vector's items.","summary":"

Iterates over the specified column in the matrix, returning the Vector's items.

","abstract":false,"args":[{"name":"j","doc":null,"default_value":"","external_name":"j","restriction":""}],"args_string":"(j, &block)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L274","def":{"name":"column","args":[{"name":"j","doc":null,"default_value":"","external_name":"j","restriction":""}],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"if j >= column_count || j < (-column_count)\n return self\nend\nrow_count.times do |i|\n yield rows[i][j]\nend\nself\n"}},{"id":"column(j)-instance-method","html_id":"column(j)-instance-method","name":"column","doc":"Returns column vector number `j` of the matrix as a `Vector` (starting at 0 like an array).","summary":"

Returns column vector number j of the matrix as a Vector (starting at 0 like an array).

","abstract":false,"args":[{"name":"j","doc":null,"default_value":"","external_name":"j","restriction":""}],"args_string":"(j)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L265","def":{"name":"column","args":[{"name":"j","doc":null,"default_value":"","external_name":"j","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if j >= column_count || j < (-column_count)\n raise(\"Index out of range\")\nend\ncol = Array(Float64).new(row_count) do |i|\n rows[i][j]\nend\nVector.create(col)\n"}},{"id":"column?(j)-instance-method","html_id":"column?(j)-instance-method","name":"column?","doc":"Returns column vector number `j` of the matrix as a `Vector` (starting at 0 like an array).","summary":"

Returns column vector number j of the matrix as a Vector (starting at 0 like an array).

","abstract":false,"args":[{"name":"j","doc":null,"default_value":"","external_name":"j","restriction":""}],"args_string":"(j)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L256","def":{"name":"column?","args":[{"name":"j","doc":null,"default_value":"","external_name":"j","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if j >= column_count || j < (-column_count)\n return nil\nend\ncol = Array(Float64).new(row_count) do |i|\n rows[i][j]\nend\nVector.create(col)\n"}},{"id":"column_count:Int32-instance-method","html_id":"column_count:Int32-instance-method","name":"column_count","doc":null,"summary":null,"abstract":false,"args":[],"args_string":" : Int32","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L11","def":{"name":"column_count","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Int32","visibility":"Public","body":"@column_count"}},{"id":"column_vectors-instance-method","html_id":"column_vectors-instance-method","name":"column_vectors","doc":"Returns an array of the column vectors of the matrix. See `Vector`.","summary":"

Returns an array of the column vectors of the matrix.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L283","def":{"name":"column_vectors","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Array(Vector).new(column_count) do |i|\n column(i)\nend"}},{"id":"determinant-instance-method","html_id":"determinant-instance-method","name":"determinant","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L354","def":{"name":"determinant","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if square?\nelse\n raise(\"Dimention mismatch: `Matrix#determinant` requires a square matrix.\")\nend\nm = rows\ncase row_count\nwhen 0\n +1\nwhen 1\n +m[0][0]\nwhen 2\n ((+m[0][0]) * m[1][1]) - (m[0][1] * m[1][0])\nwhen 3\n m0, m1, m2 = m\n (((((((+m0[0]) * m1[1]) * m2[2]) - ((m0[0] * m1[2]) * m2[1])) - ((m0[1] * m1[0]) * m2[2])) + ((m0[1] * m1[2]) * m2[0])) + ((m0[2] * m1[0]) * m2[1])) - ((m0[2] * m1[1]) * m2[0])\nwhen 4\n m0, m1, m2, m3 = m\n ((((((((((((((((((((((((((+m0[0]) * m1[1]) * m2[2]) * m3[3]) - (((m0[0] * m1[1]) * m2[3]) * m3[2])) - (((m0[0] * m1[2]) * m2[1]) * m3[3])) + (((m0[0] * m1[2]) * m2[3]) * m3[1])) + (((m0[0] * m1[3]) * m2[1]) * m3[2])) - (((m0[0] * m1[3]) * m2[2]) * m3[1])) - (((m0[1] * m1[0]) * m2[2]) * m3[3])) + (((m0[1] * m1[0]) * m2[3]) * m3[2])) + (((m0[1] * m1[2]) * m2[0]) * m3[3])) - (((m0[1] * m1[2]) * m2[3]) * m3[0])) - (((m0[1] * m1[3]) * m2[0]) * m3[2])) + (((m0[1] * m1[3]) * m2[2]) * m3[0])) + (((m0[2] * m1[0]) * m2[1]) * m3[3])) - (((m0[2] * m1[0]) * m2[3]) * m3[1])) - (((m0[2] * m1[1]) * m2[0]) * m3[3])) + (((m0[2] * m1[1]) * m2[3]) * m3[0])) + (((m0[2] * m1[3]) * m2[0]) * m3[1])) - (((m0[2] * m1[3]) * m2[1]) * m3[0])) - (((m0[3] * m1[0]) * m2[1]) * m3[2])) + (((m0[3] * m1[0]) * m2[2]) * m3[1])) + (((m0[3] * m1[1]) * m2[0]) * m3[2])) - (((m0[3] * m1[1]) * m2[2]) * m3[0])) - (((m0[3] * m1[2]) * m2[0]) * m3[1])) + (((m0[3] * m1[2]) * m2[1]) * m3[0])\nelse\n determinant_bareiss\nend\n"}},{"id":"first_minor(row,column)-instance-method","html_id":"first_minor(row,column)-instance-method","name":"first_minor","doc":null,"summary":null,"abstract":false,"args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":""},{"name":"column","doc":null,"default_value":"","external_name":"column","restriction":""}],"args_string":"(row, column)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L429","def":{"name":"first_minor","args":[{"name":"row","doc":null,"default_value":"","external_name":"row","restriction":""},{"name":"column","doc":null,"default_value":"","external_name":"column","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if empty?\n raise(\"first_minor of empty matrix is not defined\")\nend\nif 0 <= row && row < row_count\nelse\n raise(ArgumentError.new(\"invalid row (#{row.inspect} for 0..#{row_count - 1})\"))\nend\nif 0 <= column && column < column_count\nelse\n raise(ArgumentError.new(\"invalid column (#{column.inspect} for 0..#{column_count - 1})\"))\nend\narrays = to_a.map(&.to_a)\narrays.delete_at(row)\narrays.each do |array|\n array.delete_at(column)\nend\nMatrix.new(arrays, column_count - 1)\n"}},{"id":"inverse-instance-method","html_id":"inverse-instance-method","name":"inverse","doc":"Returns the inverse of the matrix.","summary":"

Returns the inverse of the matrix.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L304","def":{"name":"inverse","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if square?\nelse\n if square?\n else\n raise(\"Dimention mismatch: `Matrix#inverse` requires a square matrix.\")\n end\nend\n(Matrix.identity(row_count)).inverse_from(self)\n"}},{"id":"laplace_expansion(*,row=nil,column=nil)-instance-method","html_id":"laplace_expansion(*,row=nil,column=nil)-instance-method","name":"laplace_expansion","doc":"Returns the Laplace expansion along given row or column.","summary":"

Returns the Laplace expansion along given row or column.

","abstract":false,"args":[{"name":"","doc":null,"default_value":"","external_name":"","restriction":""},{"name":"row","doc":null,"default_value":"nil","external_name":"row","restriction":""},{"name":"column","doc":null,"default_value":"nil","external_name":"column","restriction":""}],"args_string":"(*, row = nil, column = nil)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L450","def":{"name":"laplace_expansion","args":[{"name":"","doc":null,"default_value":"","external_name":"","restriction":""},{"name":"row","doc":null,"default_value":"nil","external_name":"row","restriction":""},{"name":"column","doc":null,"default_value":"nil","external_name":"column","restriction":""}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"num = row || column\nif (!num) || (row && column)\n raise(ArgumentError.new(\"exactly one the row or column arguments must be specified\"))\nend\nif square?\nelse\n raise(\"Dimention mismatch: `Matrix#determinant` requires a square matrix.\")\nend\nif empty?\n raise(\"laplace_expansion of empty matrix is not defined\")\nend\nif 0 <= num && num < row_count\nelse\n raise(ArgumentError.new(\"invalid num (#{num.inspect} for 0..#{row_count - 1})\"))\nend\nif row\n (row(num)).map_with_index do |e, k|\n e * (cofactor(num, k))\n end.reduce(&.+)\nelse\n (column(num)).map_with_index do |e, k|\n e * (cofactor(k, num))\n end.reduce(&.+)\nend\n"}},{"id":"pretty_print(pp):Nil-instance-method","html_id":"pretty_print(pp):Nil-instance-method","name":"pretty_print","doc":null,"summary":null,"abstract":false,"args":[{"name":"pp","doc":null,"default_value":"","external_name":"pp","restriction":""}],"args_string":"(pp) : Nil","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L516","def":{"name":"pretty_print","args":[{"name":"pp","doc":null,"default_value":"","external_name":"pp","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Nil","visibility":"Public","body":"pp.list(\"[\", self, \"]\") do |vec|\n pp.group do\n vec.to_a.pretty_print(pp)\n end\nend"}},{"id":"row(i,&block)-instance-method","html_id":"row(i,&block)-instance-method","name":"row","doc":null,"summary":null,"abstract":false,"args":[{"name":"i","doc":null,"default_value":"","external_name":"i","restriction":""}],"args_string":"(i, &block)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L475","def":{"name":"row","args":[{"name":"i","doc":null,"default_value":"","external_name":"i","restriction":""}],"double_splat":null,"splat_index":null,"yields":0,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":""},"return_type":"","visibility":"Public","body":"(@rows.fetch(i) do\n return self\nend).each(&block)\nself\n"}},{"id":"row(i)-instance-method","html_id":"row(i)-instance-method","name":"row","doc":null,"summary":null,"abstract":false,"args":[{"name":"i","doc":null,"default_value":"","external_name":"i","restriction":""}],"args_string":"(i)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L480","def":{"name":"row","args":[{"name":"i","doc":null,"default_value":"","external_name":"i","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.create(rows.fetch(i) do\n [] of Float64\nend)"}},{"id":"row_count:Int32-instance-method","html_id":"row_count:Int32-instance-method","name":"row_count","doc":null,"summary":null,"abstract":false,"args":[],"args_string":" : Int32","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L13","def":{"name":"row_count","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Int32","visibility":"Public","body":"@row_count"}},{"id":"rows-instance-method","html_id":"rows-instance-method","name":"rows","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L484","def":{"name":"rows","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"rows = [] of Vector\nrow_count.times do |i|\n rows << self[i - 1]\nend\nrows\n"}},{"id":"square?-instance-method","html_id":"square?-instance-method","name":"square?","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L492","def":{"name":"square?","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"row_count == column_count"}},{"id":"to_s(io)-instance-method","html_id":"to_s(io)-instance-method","name":"to_s","doc":null,"summary":null,"abstract":false,"args":[{"name":"io","doc":null,"default_value":"","external_name":"io","restriction":""}],"args_string":"(io)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L502","def":{"name":"to_s","args":[{"name":"io","doc":null,"default_value":"","external_name":"io","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if empty?\n \"Matrix.empty(#{row_count}, #{column_count})\"\nelse\n io << \"Matrix[\"\n io << (map do |row|\n (\"{\" + (row.to_a.map do |e|\n e.to_s\n end.join(\", \"))) + \"}\"\n end.join(\", \"))\n io << \"]\"\nend"}},{"id":"transpose-instance-method","html_id":"transpose-instance-method","name":"transpose","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L496","def":{"name":"transpose","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if row_count.zero?\n return Matrix.empty(column_count, 0)\nend\ntransposed = rows.map do |v|\n v.to_a\nend.transpose\nMatrix.new(transposed, row_count)\n"}},{"id":"unsafe_fetch(index:Int)-instance-method","html_id":"unsafe_fetch(index:Int)-instance-method","name":"unsafe_fetch","doc":null,"summary":null,"abstract":false,"args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"}],"args_string":"(index : Int)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/matrix.cr#L525","def":{"name":"unsafe_fetch","args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@buffer[index]"}}],"macros":[],"types":[]},{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra/NDArray","path":"Apatite/LinearAlgebra/NDArray.html","kind":"class","full_name":"Apatite::LinearAlgebra::NDArray","name":"NDArray","abstract":false,"superclass":{"html_id":"github.com/watzon/apatite/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"github.com/watzon/apatite/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"github.com/watzon/apatite/Indexable","kind":"module","full_name":"Indexable","name":"Indexable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Iterable","kind":"module","full_name":"Iterable","name":"Iterable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"github.com/watzon/apatite/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"apatite/linear_algebra/ndarray.cr","line_number":2,"url":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/ndarray.cr"}],"repository_name":"github.com/watzon/apatite","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[{"html_id":"github.com/watzon/apatite/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Indexable","kind":"module","full_name":"Indexable","name":"Indexable"}],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra","kind":"module","full_name":"Apatite::LinearAlgebra","name":"LinearAlgebra"},"doc":null,"summary":null,"class_methods":[],"constructors":[{"id":"new(data:Array(Number),shape:Array(Int32)?=nil)-class-method","html_id":"new(data:Array(Number),shape:Array(Int32)?=nil)-class-method","name":"new","doc":null,"summary":null,"abstract":false,"args":[{"name":"data","doc":null,"default_value":"","external_name":"data","restriction":"Array(Number)"},{"name":"shape","doc":null,"default_value":"nil","external_name":"shape","restriction":"Array(Int32) | ::Nil"}],"args_string":"(data : Array(Number), shape : Array(Int32)? = nil)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/ndarray.cr#L18","def":{"name":"new","args":[{"name":"data","doc":null,"default_value":"","external_name":"data","restriction":"Array(Number)"},{"name":"shape","doc":null,"default_value":"nil","external_name":"shape","restriction":"Array(Int32) | ::Nil"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"_ = allocate\n_.initialize(data, shape)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"id":"[](*args,**options)-instance-method","html_id":"[](*args,**options)-instance-method","name":"[]","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/ndarray.cr#L11","def":{"name":"[]","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@data[*args, **options]"}},{"id":"[](*args,**options,&block)-instance-method","html_id":"[](*args,**options,&block)-instance-method","name":"[]","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options, &block)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/ndarray.cr#L11","def":{"name":"[]","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"@data[*args, **options] do |*yield_args|\n yield *yield_args\nend"}},{"id":"[]=(*args,**options)-instance-method","html_id":"[]=(*args,**options)-instance-method","name":"[]=","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/ndarray.cr#L13","def":{"name":"[]=","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@data[*args] = **options"}},{"id":"[]?(*args,**options)-instance-method","html_id":"[]?(*args,**options)-instance-method","name":"[]?","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/ndarray.cr#L12","def":{"name":"[]?","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@data[*args, **options]?"}},{"id":"[]?(*args,**options,&block)-instance-method","html_id":"[]?(*args,**options,&block)-instance-method","name":"[]?","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options, &block)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/ndarray.cr#L12","def":{"name":"[]?","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"@data[*args, **options]? do |*yield_args|\n yield *yield_args\nend"}},{"id":"abs-instance-method","html_id":"abs-instance-method","name":"abs","doc":"Returns the absolute value of every item in the array","summary":"

Returns the absolute value of every item in the array

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/ndarray.cr#L24","def":{"name":"abs","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"map do |e|\n e.abs\nend"}},{"id":"acos-instance-method","html_id":"acos-instance-method","name":"acos","doc":"Returns the arccosine of each element in the current array.","summary":"

Returns the arccosine of each element in the current array.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/ndarray.cr#L29","def":{"name":"acos","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":""}},{"id":"data:Array(Float64)-instance-method","html_id":"data:Array(Float64)-instance-method","name":"data","doc":null,"summary":null,"abstract":false,"args":[],"args_string":" : Array(Float64)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/ndarray.cr#L9","def":{"name":"data","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Array(Float64)","visibility":"Public","body":"@data"}},{"id":"shape:Array(Int32)-instance-method","html_id":"shape:Array(Int32)-instance-method","name":"shape","doc":null,"summary":null,"abstract":false,"args":[],"args_string":" : Array(Int32)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/ndarray.cr#L11","def":{"name":"shape","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Array(Int32)","visibility":"Public","body":"@shape"}},{"id":"size(*args,**options)-instance-method","html_id":"size(*args,**options)-instance-method","name":"size","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/ndarray.cr#L16","def":{"name":"size","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@data.size(*args, **options)"}},{"id":"size(*args,**options,&block)-instance-method","html_id":"size(*args,**options,&block)-instance-method","name":"size","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options, &block)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/ndarray.cr#L16","def":{"name":"size","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"@data.size(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"id":"to_unsafe(*args,**options)-instance-method","html_id":"to_unsafe(*args,**options)-instance-method","name":"to_unsafe","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/ndarray.cr#L15","def":{"name":"to_unsafe","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@data.to_unsafe(*args, **options)"}},{"id":"to_unsafe(*args,**options,&block)-instance-method","html_id":"to_unsafe(*args,**options,&block)-instance-method","name":"to_unsafe","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options, &block)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/ndarray.cr#L15","def":{"name":"to_unsafe","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"@data.to_unsafe(*args, **options) do |*yield_args|\n yield *yield_args\nend"}},{"id":"unsafe_fetch(*args,**options)-instance-method","html_id":"unsafe_fetch(*args,**options)-instance-method","name":"unsafe_fetch","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/ndarray.cr#L14","def":{"name":"unsafe_fetch","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@data.unsafe_fetch(*args, **options)"}},{"id":"unsafe_fetch(*args,**options,&block)-instance-method","html_id":"unsafe_fetch(*args,**options,&block)-instance-method","name":"unsafe_fetch","doc":null,"summary":null,"abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, **options, &block)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/ndarray.cr#L14","def":{"name":"unsafe_fetch","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":{"name":"options","doc":null,"default_value":"","external_name":"options","restriction":""},"splat_index":0,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"@data.unsafe_fetch(*args, **options) do |*yield_args|\n yield *yield_args\nend"}}],"macros":[],"types":[]},{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra/Vector","path":"Apatite/LinearAlgebra/Vector.html","kind":"class","full_name":"Apatite::LinearAlgebra::Vector","name":"Vector","abstract":false,"superclass":{"html_id":"github.com/watzon/apatite/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"github.com/watzon/apatite/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"github.com/watzon/apatite/Indexable","kind":"module","full_name":"Indexable","name":"Indexable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Iterable","kind":"module","full_name":"Iterable","name":"Iterable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"github.com/watzon/apatite/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"apatite/linear_algebra/vector.cr","line_number":4,"url":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr"}],"repository_name":"github.com/watzon/apatite","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[{"id":"I","name":"I","value":"Vector.create([1.0, 0.0, 0.0])","doc":"Cartesian unit vector I","summary":"

Cartesian unit vector I

"},{"id":"J","name":"J","value":"Vector.create([0.0, 1.0, 0.0])","doc":"Cartesian unit vector J","summary":"

Cartesian unit vector J

"},{"id":"K","name":"K","value":"Vector.create([0.0, 0.0, 1.0])","doc":"Cartesian unit vector K","summary":"

Cartesian unit vector K

"}],"included_modules":[{"html_id":"github.com/watzon/apatite/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Indexable","kind":"module","full_name":"Indexable","name":"Indexable"}],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":{"html_id":"github.com/watzon/apatite/Apatite/LinearAlgebra","kind":"module","full_name":"Apatite::LinearAlgebra","name":"LinearAlgebra"},"doc":"Represents a mathematical vector, and also constitutes a row or column\nof a `Matrix`","summary":"

Represents a mathematical vector, and also constitutes a row or column of a Matrix

","class_methods":[{"id":"[](*array)-class-method","html_id":"[](*array)-class-method","name":"[]","doc":null,"summary":null,"abstract":false,"args":[{"name":"array","doc":null,"default_value":"","external_name":"array","restriction":""}],"args_string":"(*array)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L156","def":{"name":"[]","args":[{"name":"array","doc":null,"default_value":"","external_name":"array","restriction":""}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.create(array)"}},{"id":"basis(size,index)-class-method","html_id":"basis(size,index)-class-method","name":"basis","doc":"Returns a standard basis n-vector.","summary":"

Returns a standard basis n-vector.

","abstract":false,"args":[{"name":"size","doc":null,"default_value":"","external_name":"size","restriction":""},{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":""}],"args_string":"(size, index)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L138","def":{"name":"basis","args":[{"name":"size","doc":null,"default_value":"","external_name":"size","restriction":""},{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if size < 1\n raise(ArgumentError.new(\"invalid size (#{size} for 1..)\"))\nend\nif 0 <= index && index < size\nelse\n raise(ArgumentError.new(\"invalid index (#{index} for 0...#{size})\"))\nend\nvec = Vector.new(size, 0.0)\nvec[index] = 1.0\nvec\n"}},{"id":"create(elements:Indexable(Number))-class-method","html_id":"create(elements:Indexable(Number))-class-method","name":"create","doc":"Creates a new `Vector` from the elements of another `Indexable`\ncollection.\n\n```\nVector.create([1, 2, 3]) # Vector{1.0, 2.0, 3.0}\n```","summary":"

Creates a new Vector from the elements of another Indexable collection.

","abstract":false,"args":[{"name":"elements","doc":null,"default_value":"","external_name":"elements","restriction":"Indexable(Number)"}],"args_string":"(elements : Indexable(Number))","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L118","def":{"name":"create","args":[{"name":"elements","doc":null,"default_value":"","external_name":"elements","restriction":"Indexable(Number)"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"vec = Vector.new\nelements.each do |el|\n vec.push(el.to_f64)\nend\nvec\n"}},{"id":"ones(n)-class-method","html_id":"ones(n)-class-method","name":"ones","doc":"Create a new vector of size `n` filled with ones.","summary":"

Create a new vector of size n filled with ones.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L152","def":{"name":"ones","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.new(n, 1.0)"}},{"id":"random(n,range=nil)-class-method","html_id":"random(n,range=nil)-class-method","name":"random","doc":"Creates a new `Vector` of size `n` filled with random numbers. A `range`\ncan optionally be passed in if you want to limit the random numbers\nto a given range.","summary":"

Creates a new Vector of size n filled with random numbers.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""},{"name":"range","doc":null,"default_value":"nil","external_name":"range","restriction":""}],"args_string":"(n, range = nil)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L129","def":{"name":"random","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""},{"name":"range","doc":null,"default_value":"nil","external_name":"range","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"vec = Vector.new(n)\nn.times do\n vec.push(rand((range || -1e+1)..1e+1))\nend\nvec\n"}},{"id":"zeros(n)-class-method","html_id":"zeros(n)-class-method","name":"zeros","doc":"Create a new vector of size `n` filled with zeros.","summary":"

Create a new vector of size n filled with zeros.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L147","def":{"name":"zeros","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.new(n, 0.0)"}}],"constructors":[{"id":"build(capacity:Int,&block):self-class-method","html_id":"build(capacity:Int,&block):self-class-method","name":"build","doc":"Creates a new `Vector`, allocating an internal buffer with the given *capacity*,\nand yielding that buffer. The given block must return the desired size of the vector.\n\nThis method is **unsafe**.\n\n```\nVector.build(3) do |buffer|\n LibSome.fill_buffer_and_return_number_of_elements_filled(buffer)\nend\n```","summary":"

Creates a new Vector, allocating an internal buffer with the given capacity, and yielding that buffer.

","abstract":false,"args":[{"name":"capacity","doc":null,"default_value":"","external_name":"capacity","restriction":"Int"}],"args_string":"(capacity : Int, &block) : self","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L106","def":{"name":"build","args":[{"name":"capacity","doc":null,"default_value":"","external_name":"capacity","restriction":"Int"}],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"self","visibility":"Public","body":"vec = Vector.new(capacity)\nvec.size = (yield vec.to_unsafe).to_i\nvec\n"}},{"id":"new(size:Int,value:Float64)-class-method","html_id":"new(size:Int,value:Float64)-class-method","name":"new","doc":"Creates a new `Vector` of the given *size* filled with the same *value* in each position.\n\n```\nVector.new(3, 1.0) # => Vector{1.0, 1.0, 1.0}\n```","summary":"

Creates a new Vector of the given size filled with the same value in each position.

","abstract":false,"args":[{"name":"size","doc":null,"default_value":"","external_name":"size","restriction":"Int"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":"Float64"}],"args_string":"(size : Int, value : Float64)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L63","def":{"name":"new","args":[{"name":"size","doc":null,"default_value":"","external_name":"size","restriction":"Int"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":"Float64"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"_ = allocate\n_.initialize(size, value)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"id":"new(initial_capacity:Int)-class-method","html_id":"new(initial_capacity:Int)-class-method","name":"new","doc":"Creates a new empty `Vector` backed by a buffer that is initially\n`initial_capacity` big.\n\nThe *initial_capacity* is useful to avoid unnecessary reallocations\nof the internal buffer in case of growth. If you have an estimate\nof the maximum number of elements an vector will hold, the vector should\nbe initialized with that capacity for improved performance.\n\n```\nvec = Vector.new(5)\nvec.size # => 0\n```","summary":"

Creates a new empty Vector backed by a buffer that is initially initial_capacity big.

","abstract":false,"args":[{"name":"initial_capacity","doc":null,"default_value":"","external_name":"initial_capacity","restriction":"Int"}],"args_string":"(initial_capacity : Int)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L43","def":{"name":"new","args":[{"name":"initial_capacity","doc":null,"default_value":"","external_name":"initial_capacity","restriction":"Int"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"_ = allocate\n_.initialize(initial_capacity)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"id":"new-class-method","html_id":"new-class-method","name":"new","doc":"Create a new empty `Vector`.","summary":"

Create a new empty Vector.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L25","def":{"name":"new","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"_ = allocate\n_.initialize\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"id":"new(size:Int,&block:Int32->Float64)-class-method","html_id":"new(size:Int,&block:Int32->Float64)-class-method","name":"new","doc":"Creates a new `Vector` of the given *size* and invokes the given block once\nfor each index of `self`, assigning the block's value in that index.\n\n```\nVector.new(3) { |i| (i + 1.0) ** 2.0 } # => Vector{1.0, 4.0, 9.0}\n\nvec = Vector.new(3) { 5.0 }\nvec # => Vector{5.0, 5.0, 5.0}\n```","summary":"

Creates a new Vector of the given size and invokes the given block once for each index of self, assigning the block's value in that index.

","abstract":false,"args":[{"name":"size","doc":null,"default_value":"","external_name":"size","restriction":"Int"}],"args_string":"(size : Int, &block : Int32 -> Float64)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L87","def":{"name":"new","args":[{"name":"size","doc":null,"default_value":"","external_name":"size","restriction":"Int"}],"double_splat":null,"splat_index":null,"yields":1,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":"(Int32 -> Float64)"},"return_type":"","visibility":"Public","body":"Vector.build(size) do |buffer|\n size.to_i.times do |i|\n buffer[i] = yield i\n end\n size\nend"}}],"instance_methods":[{"id":"*(other)-instance-method","html_id":"*(other)-instance-method","name":"*","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"args_string":"(other)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L370","def":{"name":"*","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"multiply(other)"}},{"id":"+(other)-instance-method","html_id":"+(other)-instance-method","name":"+","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"args_string":"(other)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L362","def":{"name":"+","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"add(other)"}},{"id":"-(other)-instance-method","html_id":"-(other)-instance-method","name":"-","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"args_string":"(other)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L366","def":{"name":"-","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"subtract(other)"}},{"id":"<<(value:Float64)-instance-method","html_id":"<<(value:Float64)-instance-method","name":"<<","doc":"Alias for `#push`","summary":"

Alias for #push

","abstract":false,"args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":"Float64"}],"args_string":"(value : Float64)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L349","def":{"name":"<<","args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":"Float64"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"push(value)"}},{"id":"(other)-instance-method","html_id":"(other)-instance-method","name":"<=>","doc":"Combined comparison operator. Returns *0* if `self` equals *other*, *1* if\n`self` is greater than *other* and *-1* if `self` is smaller than *other*.\n\nIt compares the elements of both vectors in the same position using the\n`<=>` operator. As soon as one of such comparisons returns a non-zero\nvalue, that result is the return value of the comparison.\n\nIf all elements are equal, the comparison is based on the size of the vectors.\n\n```\nVector{8.0} <=> Vector(1.0, 2.0, 3.0} # => 1\nVector{2.0} <=> Vector{4.0, 2.0, 3.0} # => -1\nVector{1.0, 2.0} <=> Vector{1.0, 2.0} # => 0\n```","summary":"

Combined comparison operator.

","abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"args_string":"(other)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L339","def":{"name":"<=>","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"min_size = Math.min(size, other.size)\n0.upto(min_size - 1) do |i|\n n = @buffer[i] <=> other.to_unsafe[i]\n if n != 0\n return n\n end\nend\nsize <=> other.size\n"}},{"id":"==(other:Vector)-instance-method","html_id":"==(other:Vector)-instance-method","name":"==","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Vector"}],"args_string":"(other : Vector)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L353","def":{"name":"==","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Vector"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"equals?(other) do |x, y|\n x == y\nend"}},{"id":"[](start:Int,count:Int)-instance-method","html_id":"[](start:Int,count:Int)-instance-method","name":"[]","doc":"Returns count or less (if there aren't enough) elements starting at the\ngiven start index.\n\nNegative indices count backward from the end of the vector (-1 is the last\nelement). Additionally, an empty vector is returned when the starting index\nfor an element range is at the end of the vector.\n\nRaises `IndexError` if the starting index is out of range.\n\n```\nv = Vector{1.0, 2.0, 3.0, 4.0, 5.0}\nv[1, 3] # => Vector{2.0, 3.0, 4.0}\nv[6, 10] # raise IndexError\n```","summary":"

Returns count or less (if there aren't enough) elements starting at the given start index.

","abstract":false,"args":[{"name":"start","doc":null,"default_value":"","external_name":"start","restriction":"Int"},{"name":"count","doc":null,"default_value":"","external_name":"count","restriction":"Int"}],"args_string":"(start : Int, count : Int)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L191","def":{"name":"[]","args":[{"name":"start","doc":null,"default_value":"","external_name":"start","restriction":"Int"},{"name":"count","doc":null,"default_value":"","external_name":"count","restriction":"Int"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if count < 0\n raise(ArgumentError.new(\"Negative count: #{count}\"))\nend\nif start == size\n return Vector.new\nend\nif start < 0\n start = start + size\nend\nif 0 <= start && start <= size\nelse\n raise(IndexError.new)\nend\nif count == 0\n return Vector.new\nend\ncount = Math.min(count, size - start)\nVector.build(count) do |buffer|\n buffer.copy_from(@buffer + start, count)\n count\nend\n"}},{"id":"[](range:Range(Int,Int))-instance-method","html_id":"[](range:Range(Int,Int))-instance-method","name":"[]","doc":"Returns all elements that are within the given range.\n\nNegative indices count backward from the end of the vector (-1 is the last\nelement). Additionally, an empty vector is returned when the starting index\nfor an element range is at the end of the vector.\n\nRaises `IndexError` if the starting index is out of range.\n\n```\nv = Vector{1.0, 2.0, 3.0, 4.0, 5.0}\nv[1..3] # => Vector{2.0, 3.0, 4.0}\nv[6..10] # raise IndexError\n```","summary":"

Returns all elements that are within the given range.

","abstract":false,"args":[{"name":"range","doc":null,"default_value":"","external_name":"range","restriction":"Range(Int, Int)"}],"args_string":"(range : Range(Int, Int))","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L173","def":{"name":"[]","args":[{"name":"range","doc":null,"default_value":"","external_name":"range","restriction":"Range(Int, Int)"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"self[*Indexable.range_to_index_and_count(range, size)]"}},{"id":"[]=(index:Int,count:Int,values:Vector)-instance-method","html_id":"[]=(index:Int,count:Int,values:Vector)-instance-method","name":"[]=","doc":"Replaces a subrange with the elements of the given vector.\n\n```\nvec = Vector{1.0, 2.0, 3.0, 4.0, 5.0}\nvec[1, 3] = Vector{6.0, 7.0, 8.0}\nvec # = Vector{1.0, 6.0, 7.0, 8.0, 5.0}\n\nvec = Vector{1.0, 2.0, 3.0, 4.0, 5.0}\nvec[1, 3] = Vector{6.0, 7.0}\nvec # = Vector{1.0, 6.0, 7.0, 5.0}\n```","summary":"

Replaces a subrange with the elements of the given vector.

","abstract":false,"args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"},{"name":"count","doc":null,"default_value":"","external_name":"count","restriction":"Int"},{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":"Vector"}],"args_string":"(index : Int, count : Int, values : Vector)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L297","def":{"name":"[]=","args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"},{"name":"count","doc":null,"default_value":"","external_name":"count","restriction":"Int"},{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":"Vector"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if count < 0\n raise(ArgumentError.new(\"Negative count: #{count}\"))\nend\nindex = check_index_out_of_bounds(index)\ncount = ((index + count) <= size) ? count : size - index\ndiff = values.size - count\nif diff == 0\n (@buffer + index).copy_from(values.to_unsafe, values.size)\nelse\n if diff < 0\n diff = -diff\n (@buffer + index).copy_from(values.to_unsafe, values.size)\n ((@buffer + index) + values.size).move_from((@buffer + index) + count, (size - index) - count)\n ((@buffer + @size) - diff).clear(diff)\n @size = @size - diff\n else\n resize_to_capacity(Math.pw2ceil(@size + diff))\n ((@buffer + index) + values.size).move_from((@buffer + index) + count, (size - index) - count)\n (@buffer + index).copy_from(values.to_unsafe, values.size)\n @size = @size + diff\n end\nend\nvalues\n"}},{"id":"[]=(index:Int,count:Int,value)-instance-method","html_id":"[]=(index:Int,count:Int,value)-instance-method","name":"[]=","doc":"Replaces a subrange with a single value. All elements in the range\n`index...index+count` are removed and replaced by a single element\n*value*.\n\nIf *count* is zero, *value* is inserted at *index*.\n\nNegative values of *index* count from the end of the vector.\n\n```\nvec = Vector{1.0, 2.0, 3.0, 4.0, 5.0}\nvec[1, 3] = 6.0\nvec # => Vector{1.0, 6.0, 5.0}\n\nvec = Vector{1.0, 2.0, 3.0, 4.0, 5.0}\nvec[1, 0] = 6.0\nvec # => Vector{1.0, 6.0, 2.0, 3.0, 4.0, 5.0}\n```","summary":"

Replaces a subrange with a single value.

","abstract":false,"args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"},{"name":"count","doc":null,"default_value":"","external_name":"count","restriction":"Int"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(index : Int, count : Int, value)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L248","def":{"name":"[]=","args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"},{"name":"count","doc":null,"default_value":"","external_name":"count","restriction":"Int"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if count < 0\n raise(ArgumentError.new(\"Negative count: #{count}\"))\nend\nvalue = value.to_f64\nindex = check_index_out_of_bounds(index)\ncount = ((index + count) <= size) ? count : size - index\ncase count\nwhen 0\n insert(index, value)\nwhen 1\n @buffer[index] = value\nelse\n diff = count - 1\n ((@buffer + index) + 1).move_from((@buffer + index) + count, (size - index) - count)\n ((@buffer + @size) - diff).clear(diff)\n @buffer[index] = value\n @size = @size - diff\nend\nvalue\n"}},{"id":"[]=(index:Int,value)-instance-method","html_id":"[]=(index:Int,value)-instance-method","name":"[]=","doc":"Sets the given value at the given index.\n\nNegative indices can be used to start counting from the end of the array.\nRaises `IndexError` if trying to set an element outside the array's range.\n\n```\nvec = Vector{1.0, 2.0, 3.0}\nvec[0] = 5.0\np vec # => Vec{5.0, 2.0, 3.0}\n\nvec[3] = 5.0 # raises IndexError\n```","summary":"

Sets the given value at the given index.

","abstract":false,"args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(index : Int, value)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L226","def":{"name":"[]=","args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"index = check_index_out_of_bounds(index)\n@buffer[index] = value.to_f64\n"}},{"id":"[]=(range:Range(Int,Int),value)-instance-method","html_id":"[]=(range:Range(Int,Int),value)-instance-method","name":"[]=","doc":"Replaces a subrange with a single value.\n\n```\nvec = Vector{1.0, 2.0, 3.0, 4.0, 5.0}\nvec[1..3] = 6.0\nvec # = Vector{1.0, 6.0, 5.0}\n\nvec = Vector{1.0, 2.0, 3.0, 4.0, 5.0}\nvec[1...1] = 6\nvec # = Vector{1.0, 6.0, 2.0, 3.0, 4.0, 5.0}\n```","summary":"

Replaces a subrange with a single value.

","abstract":false,"args":[{"name":"range","doc":null,"default_value":"","external_name":"range","restriction":"Range(Int, Int)"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(range : Range(Int, Int), value)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L282","def":{"name":"[]=","args":[{"name":"range","doc":null,"default_value":"","external_name":"range","restriction":"Range(Int, Int)"},{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"self[*Indexable.range_to_index_and_count(range, size)] = value.to_f64"}},{"id":"add(value)-instance-method","html_id":"add(value)-instance-method","name":"add","doc":"When the input is a number, this returns the result of adding\nit to all vector elements. When it's a vector, the vectors\nwill be added together.","summary":"

When the input is a number, this returns the result of adding it to all vector elements.

","abstract":false,"args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(value)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L488","def":{"name":"add","args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"run_binary_op(value) do |a, b|\n a + b\nend"}},{"id":"angle_from(vector)-instance-method","html_id":"angle_from(vector)-instance-method","name":"angle_from","doc":"Returns the angle between this vector and another in radians.\nIf the vectors are mirrored across their axes this will return `nil`.","summary":"

Returns the angle between this vector and another in radians.

","abstract":false,"args":[{"name":"vector","doc":null,"default_value":"","external_name":"vector","restriction":""}],"args_string":"(vector)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L440","def":{"name":"angle_from","args":[{"name":"vector","doc":null,"default_value":"","external_name":"vector","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"v = vector.is_a?(Vector) ? vector : Vector.create(vector)\nif size == v.size\nelse\n raise(\"Cannot compute the angle between vectors with different dimensionality\")\nend\ndot = 0_f64\nmod1 = 0_f64\nmod2 = 0_f64\n(zip(vector)).each do |x, v|\n dot = dot + (x * v)\n mod1 = mod1 + (x * x)\n mod2 = mod2 + (v * v)\nend\nmod1 = Math.sqrt(mod1)\nmod2 = Math.sqrt(mod2)\nif (mod2 * mod2) == 0\n return 0.0\nend\ntheta = (dot / (mod1 * mod2)).clamp(-1, 1)\nMath.acos(theta)\n"}},{"id":"antiparallel_to?(vector)-instance-method","html_id":"antiparallel_to?(vector)-instance-method","name":"antiparallel_to?","doc":"Returns whether the vectors are antiparallel to each other.","summary":"

Returns whether the vectors are antiparallel to each other.

","abstract":false,"args":[{"name":"vector","doc":null,"default_value":"","external_name":"vector","restriction":""}],"args_string":"(vector)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L475","def":{"name":"antiparallel_to?","args":[{"name":"vector","doc":null,"default_value":"","external_name":"vector","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"angle = angle_from(vector)\n(angle - Math::PI).abs <= Apatite.precision\n"}},{"id":"augment(elements)-instance-method","html_id":"augment(elements)-instance-method","name":"augment","doc":"Returns a new vector with the provided `elements` concatenated\non the end.","summary":"

Returns a new vector with the provided elements concatenated on the end.

","abstract":false,"args":[{"name":"elements","doc":null,"default_value":"","external_name":"elements","restriction":""}],"args_string":"(elements)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L556","def":{"name":"augment","args":[{"name":"elements","doc":null,"default_value":"","external_name":"elements","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"elements = elements.is_a?(Vector) ? elements : Vector.create(elements)\nconcat(elements)\n"}},{"id":"chomp(n)-instance-method","html_id":"chomp(n)-instance-method","name":"chomp","doc":"Returns a new vector with the first `n` elements removed from\nthe beginning.","summary":"

Returns a new vector with the first n elements removed from the beginning.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L541","def":{"name":"chomp","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"elements = [] of Float64\neach_with_index do |e, i|\n if i >= n\n elements << e\n end\nend\nVector.create(elements)\n"}},{"id":"clear-instance-method","html_id":"clear-instance-method","name":"clear","doc":"Removes all elements from self.\n\n```\nvec = Vector{1.0, 2.0, 3.0}\nvec.clear # => Vector{}\n```","summary":"

Removes all elements from self.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L782","def":{"name":"clear","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@buffer.clear(@size)\n@size = 0\nself\n"}},{"id":"clone-instance-method","html_id":"clone-instance-method","name":"clone","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L374","def":{"name":"clone","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.create(@elements.clone)"}},{"id":"concat(other:Vector)-instance-method","html_id":"concat(other:Vector)-instance-method","name":"concat","doc":null,"summary":null,"abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Vector"}],"args_string":"(other : Vector)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L731","def":{"name":"concat","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":"Vector"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"other_size = other.size\nnew_size = size + other_size\nif new_size > @capacity\n resize_to_capacity(Math.pw2ceil(new_size))\nend\n(@buffer + @size).copy_from(other.to_unsafe, other_size)\n@size = new_size\nself\n"}},{"id":"covector-instance-method","html_id":"covector-instance-method","name":"covector","doc":"Creates a single-row matrix from this vector.","summary":"

Creates a single-row matrix from this vector.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L601","def":{"name":"covector","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.row_vector(self)"}},{"id":"cross(*vs)-instance-method","html_id":"cross(*vs)-instance-method","name":"cross","doc":"Returns the cross product of this vector with the others.\n\n```\nv1 = Vector{1.0, 0.0, 0.0}\nv2 = Vector{0.0, 1.0, 0.0}\nv1.cross(v2) => Vector{0.0, 0.0, 1.0}\n```","summary":"

Returns the cross product of this vector with the others.

","abstract":false,"args":[{"name":"vs","doc":null,"default_value":"","external_name":"vs","restriction":""}],"args_string":"(*vs)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L518","def":{"name":"cross","args":[{"name":"vs","doc":null,"default_value":"","external_name":"vs","restriction":""}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if size >= 2\nelse\n raise(\"cross product is not defined on vectors of dimension #{size}\")\nend\nif vs.size == (size - 2)\nelse\n raise(ArgumentError.new(\"wrong number of arguments (#{vs.size} for #{size - 2})\"))\nend\nvs.each do |v|\n if v.size == size\n else\n raise(\"Dimension mismatch. Vectors not all the same size.\")\n end\nend\ncase size\nwhen 2\n Vector[-@buffer[1], @buffer[0]]\nwhen 3\n v = vs[0]\n Vector[(v[2] * @buffer[1]) - (v[1] * @buffer[2]), (v[0] * @buffer[2]) - (v[2] * @buffer[0]), (v[1] * @buffer[0]) - (v[0] * @buffer[1])]\nelse\nend\n"}},{"id":"distance_from(obj)-instance-method","html_id":"distance_from(obj)-instance-method","name":"distance_from","doc":"Gets this vector's distance from the argument, when considered\na point in space.","summary":"

Gets this vector's distance from the argument, when considered a point in space.

","abstract":false,"args":[{"name":"obj","doc":null,"default_value":"","external_name":"obj","restriction":""}],"args_string":"(obj)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L629","def":{"name":"distance_from","args":[{"name":"obj","doc":null,"default_value":"","external_name":"obj","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if object.is_a?(Plane) || object.is_a?(Line)\n return object.distance_from(self)\nend\nv = elements.is_a?(Vector) ? elements.elements : elements\nif v.size == @elements.size\nelse\n return nil\nend\nsum = 0\npart = 0\neach_with_index do |x, i|\n part = x - v[i - 1]\n sum = sum + (part * part)\nend\nMath.sqrt(sum)\n"}},{"id":"dot(other)-instance-method","html_id":"dot(other)-instance-method","name":"dot","doc":"Get the scalar (dot) product of this vector with `vector`.\n\n[https://en.wikipedia.org/wiki/Scalar_product](https://en.wikipedia.org/wiki/Scalar_product)","summary":"

Get the scalar (dot) product of this vector with vector.

","abstract":false,"args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"args_string":"(other)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L574","def":{"name":"dot","args":[{"name":"other","doc":null,"default_value":"","external_name":"other","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"other = other.is_a?(Vector) ? other : Vector.create(other)\nif size == other.size\nelse\n raise(\"Cannot compute the dot product of vectors with different dimensionality\")\nend\nproduct = 0\n(0...size).each do |i|\n product = product + (self[i] * other[i])\nend\nproduct\n"}},{"id":"e(i)-instance-method","html_id":"e(i)-instance-method","name":"e","doc":"Returns the `ith` element of the vector. Returns `nil` if `i`\nis out of bounds. Indexing starts from 1.","summary":"

Returns the ith element of the vector.

","abstract":false,"args":[{"name":"i","doc":null,"default_value":"","external_name":"i","restriction":""}],"args_string":"(i)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L426","def":{"name":"e","args":[{"name":"i","doc":null,"default_value":"","external_name":"i","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"(i < 1 || i > @size) ? nil : self[i - 1]"}},{"id":"independent?(*vs)-instance-method","html_id":"independent?(*vs)-instance-method","name":"independent?","doc":"Returns true if all vectors are linearly independent.","summary":"

Returns true if all vectors are linearly independent.

","abstract":false,"args":[{"name":"vs","doc":null,"default_value":"","external_name":"vs","restriction":""}],"args_string":"(*vs)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L384","def":{"name":"independent?","args":[{"name":"vs","doc":null,"default_value":"","external_name":"vs","restriction":""}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"vs.each do |v|\n if v.size == vs.first.size\n else\n raise(\"Dimension mismatch. Vectors not all the same size.\")\n end\nend\nif vs.size > sv.first.size\n return false\nend\nMatrix[*vs].rank.equal?(vs.count)\n"}},{"id":"lies_in(plane)-instance-method","html_id":"lies_in(plane)-instance-method","name":"lies_in","doc":"Returns true if the vector is a point on the given plane.","summary":"

Returns true if the vector is a point on the given plane.

","abstract":false,"args":[{"name":"plane","doc":null,"default_value":"","external_name":"plane","restriction":""}],"args_string":"(plane)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L654","def":{"name":"lies_in","args":[{"name":"plane","doc":null,"default_value":"","external_name":"plane","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"plane.contains(self)"}},{"id":"lies_on(line)-instance-method","html_id":"lies_on(line)-instance-method","name":"lies_on","doc":"Returns true if the vector is a point on the given line","summary":"

Returns true if the vector is a point on the given line

","abstract":false,"args":[{"name":"line","doc":null,"default_value":"","external_name":"line","restriction":""}],"args_string":"(line)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L649","def":{"name":"lies_on","args":[{"name":"line","doc":null,"default_value":"","external_name":"line","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"line.contains(self)"}},{"id":"log-instance-method","html_id":"log-instance-method","name":"log","doc":"Return a new `Vector` with the log of every item in `self`.","summary":"

Return a new Vector with the log of every item in self.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L562","def":{"name":"log","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"map do |x|\n Math.log(x)\nend"}},{"id":"magnitude-instance-method","html_id":"magnitude-instance-method","name":"magnitude","doc":"Returns the magnitude/euclidian norm of this vector.\n\n[https://en.wikipedia.org/wiki/Euclidean_distance](https://en.wikipedia.org/wiki/Euclidean_distance)","summary":"

Returns the magnitude/euclidian norm of this vector.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L419","def":{"name":"magnitude","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"sum = reduce(0.0) do |acc, e|\n acc = acc + (e * e)\nend\nMath.sqrt(sum)\n"}},{"id":"map(&block)-instance-method","html_id":"map(&block)-instance-method","name":"map","doc":"Invokes the given block for each element of `self`.","summary":"

Invokes the given block for each element of self.

","abstract":false,"args":[],"args_string":"(&block)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L379","def":{"name":"map","args":[],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.new(size) do |i|\n yield @buffer[i]\nend"}},{"id":"map!(&block)-instance-method","html_id":"map!(&block)-instance-method","name":"map!","doc":"Invokes the given block for each element of `self`, replacing the element\nwith the value returned by the block. Returns `self`.\n\n```\nvec = Vector{1.0, 2.0, 3.0}\nvec.map! { |x| x * x }\na # => Vector{1.0, 4.0, 9.0}\n```","summary":"

Invokes the given block for each element of self, replacing the element with the value returned by the block.

","abstract":false,"args":[],"args_string":"(&block)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L400","def":{"name":"map!","args":[],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"@buffer.map!(size) do |e|\n yield e\nend\nself\n"}},{"id":"map_with_index(&block)-instance-method","html_id":"map_with_index(&block)-instance-method","name":"map_with_index","doc":"Optimized version of `Enumerable#map_with_index`.","summary":"

Optimized version of Enumerable#map_with_index.

","abstract":false,"args":[],"args_string":"(&block)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L406","def":{"name":"map_with_index","args":[],"double_splat":null,"splat_index":null,"yields":2,"block_arg":null,"return_type":"","visibility":"Public","body":"Vector.new(size) do |i|\n yield @buffer[i], i\nend"}},{"id":"map_with_index!(&block)-instance-method","html_id":"map_with_index!(&block)-instance-method","name":"map_with_index!","doc":"Like `map_with_index`, but mutates `self` instead of allocating a new object.","summary":"

Like #map_with_index, but mutates self instead of allocating a new object.

","abstract":false,"args":[],"args_string":"(&block)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L411","def":{"name":"map_with_index!","args":[],"double_splat":null,"splat_index":null,"yields":2,"block_arg":null,"return_type":"","visibility":"Public","body":"to_unsafe.map_with_index!(size) do |e, i|\n yield e, i\nend\nself\n"}},{"id":"max-instance-method","html_id":"max-instance-method","name":"max","doc":"Returns the (absolute) largest element in this vector.","summary":"

Returns the (absolute) largest element in this vector.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L589","def":{"name":"max","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"reduce do |acc, i|\n i.abs > acc.abs ? i : acc\nend"}},{"id":"max_index-instance-method","html_id":"max_index-instance-method","name":"max_index","doc":"Gets the index of the largest element in this vector.","summary":"

Gets the index of the largest element in this vector.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L594","def":{"name":"max_index","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"idx = 0\neach_with_index do |e, i|\n idx = e.abs > self[idx].abs ? i : idx\nend\nidx\n"}},{"id":"multiply(value)-instance-method","html_id":"multiply(value)-instance-method","name":"multiply","doc":"When the input is a number, this returns the result of multiplying\nit to all vector elements. When it's a vector, the vectors\nwill be element-wise multiplied.","summary":"

When the input is a number, this returns the result of multiplying it to all vector elements.

","abstract":false,"args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(value)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L502","def":{"name":"multiply","args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"run_binary_op(value) do |a, b|\n a * b\nend"}},{"id":"parallel_to?(vector)-instance-method","html_id":"parallel_to?(vector)-instance-method","name":"parallel_to?","doc":"Returns whether the vectors are parallel to each other.","summary":"

Returns whether the vectors are parallel to each other.

","abstract":false,"args":[{"name":"vector","doc":null,"default_value":"","external_name":"vector","restriction":""}],"args_string":"(vector)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L469","def":{"name":"parallel_to?","args":[{"name":"vector","doc":null,"default_value":"","external_name":"vector","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"angle = angle_from(vector)\nangle <= Apatite.precision\n"}},{"id":"perpendicular_to?(vector)-instance-method","html_id":"perpendicular_to?(vector)-instance-method","name":"perpendicular_to?","doc":"Returns whether the vectors are perpendicular to each other.","summary":"

Returns whether the vectors are perpendicular to each other.

","abstract":false,"args":[{"name":"vector","doc":null,"default_value":"","external_name":"vector","restriction":""}],"args_string":"(vector)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L481","def":{"name":"perpendicular_to?","args":[{"name":"vector","doc":null,"default_value":"","external_name":"vector","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"(dot(vector)).abs <= Apatite.precision"}},{"id":"pretty_print(pp):Nil-instance-method","html_id":"pretty_print(pp):Nil-instance-method","name":"pretty_print","doc":null,"summary":null,"abstract":false,"args":[{"name":"pp","doc":null,"default_value":"","external_name":"pp","restriction":""}],"args_string":"(pp) : Nil","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L754","def":{"name":"pretty_print","args":[{"name":"pp","doc":null,"default_value":"","external_name":"pp","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Nil","visibility":"Public","body":"pp.list(\"Vector{\", self, \"}\")"}},{"id":"product-instance-method","html_id":"product-instance-method","name":"product","doc":"Get the product of all elements in this vector.","summary":"

Get the product of all elements in this vector.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L567","def":{"name":"product","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"reduce do |acc, v|\n acc = acc * v\nend"}},{"id":"push(*values:Float64)-instance-method","html_id":"push(*values:Float64)-instance-method","name":"push","doc":null,"summary":null,"abstract":false,"args":[{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":"Float64"}],"args_string":"(*values : Float64)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L665","def":{"name":"push","args":[{"name":"values","doc":null,"default_value":"","external_name":"values","restriction":"Float64"}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"new_size = @size + values.size\nif new_size > @capacity\n resize_to_capacity(Math.pw2ceil(new_size))\nend\nvalues.each_with_index do |value, i|\n @buffer[@size + i] = value\nend\n@size = new_size\nself\n"}},{"id":"push(value:Float64)-instance-method","html_id":"push(value:Float64)-instance-method","name":"push","doc":null,"summary":null,"abstract":false,"args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":"Float64"}],"args_string":"(value : Float64)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L658","def":{"name":"push","args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":"Float64"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"check_needs_resize\n@buffer[@size] = value\n@size = @size + 1\nself\n"}},{"id":"reflection_in(object)-instance-method","html_id":"reflection_in(object)-instance-method","name":"reflection_in","doc":"Returns the result of reflecting the point in the given `object`\n(point, line, or plane).","summary":"

Returns the result of reflecting the point in the given object (point, line, or plane).

","abstract":false,"args":[{"name":"object","doc":null,"default_value":"","external_name":"object","restriction":""}],"args_string":"(object)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L684","def":{"name":"reflection_in","args":[{"name":"object","doc":null,"default_value":"","external_name":"object","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if object.is_a?(Plane) || object.is_a?(Line)\n p = @elements.dup\n c = (object.point_closest_to(p)).elements\n return Vector.create([C[0] + (C[0] - P[0]), C[1] + (C[1] - P[1]), C[2] + (C[2] - (P[2] || 0))])\nend\nq = object.is_a?(Vector) ? object.elements : object\nif @elements.size == q.size\nelse\n return nil\nend\nmap_with_index do |x, i|\n q[i - 1] + (q[i - 1] - x)\nend\n"}},{"id":"rotate(t,object)-instance-method","html_id":"rotate(t,object)-instance-method","name":"rotate","doc":"Rotates the vector about the given `object`. The object should\nbe a point if the vector is 2D, and a line if it is 3D. Be\ncareful with line directions!","summary":"

Rotates the vector about the given object.

","abstract":false,"args":[{"name":"t","doc":null,"default_value":"","external_name":"t","restriction":""},{"name":"object","doc":null,"default_value":"","external_name":"object","restriction":""}],"args_string":"(t, object)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L678","def":{"name":"rotate","args":[{"name":"t","doc":null,"default_value":"","external_name":"t","restriction":""},{"name":"object","doc":null,"default_value":"","external_name":"object","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":""}},{"id":"round-instance-method","html_id":"round-instance-method","name":"round","doc":"Gets the result of rounding the elements of the vector.","summary":"

Gets the result of rounding the elements of the vector.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L612","def":{"name":"round","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"map do |x|\n x.round\nend"}},{"id":"set_elements(elements)-instance-method","html_id":"set_elements(elements)-instance-method","name":"set_elements","doc":null,"summary":null,"abstract":false,"args":[{"name":"elements","doc":null,"default_value":"","external_name":"elements","restriction":""}],"args_string":"(elements)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L726","def":{"name":"set_elements","args":[{"name":"elements","doc":null,"default_value":"","external_name":"elements","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@elements = elements.is_a?(Vector) ? elements.elements : elements\nself\n"}},{"id":"sigmoid-instance-method","html_id":"sigmoid-instance-method","name":"sigmoid","doc":"Sums the numbers in the vector and returns a sigmoid value\nacross the whole vector.","summary":"

Sums the numbers in the vector and returns a sigmoid value across the whole vector.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L707","def":{"name":"sigmoid","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"LinearAlgebra.sigmoid(sum)"}},{"id":"size:Int32-instance-method","html_id":"size:Int32-instance-method","name":"size","doc":"Returns the number of elements in the vector","summary":"

Returns the number of elements in the vector

","abstract":false,"args":[],"args_string":" : Int32","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L24","def":{"name":"size","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Int32","visibility":"Public","body":"@size"}},{"id":"snap_to(value)-instance-method","html_id":"snap_to(value)-instance-method","name":"snap_to","doc":"Returns a copy of the vector with elements set to `value` if\nthey differ from it by less than `Apetite.precision`","summary":"

Returns a copy of the vector with elements set to value if they differ from it by less than Apetite.precision

","abstract":false,"args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(value)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L623","def":{"name":"snap_to","args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"map do |y|\n (y - x).abs <= Apetite.precision ? value : y\nend"}},{"id":"subtract(value)-instance-method","html_id":"subtract(value)-instance-method","name":"subtract","doc":"When the input is a number, this returns the result of subtracting\nit to all vector elements. When it's a vector, the vectors\nwill be subtracted.","summary":"

When the input is a number, this returns the result of subtracting it to all vector elements.

","abstract":false,"args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"args_string":"(value)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L495","def":{"name":"subtract","args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"run_binary_op(value) do |a, b|\n a - b\nend"}},{"id":"sum-instance-method","html_id":"sum-instance-method","name":"sum","doc":"Returns the sum of all elements in the vector.","summary":"

Returns the sum of all elements in the vector.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L507","def":{"name":"sum","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"reduce(0) do |acc, i|\n acc + i\nend"}},{"id":"to_3d-instance-method","html_id":"to_3d-instance-method","name":"to_3d","doc":"Utility to make sure vectors are 3D. If they are 2D, a zero\nz-component is added.","summary":"

Utility to make sure vectors are 3D.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L713","def":{"name":"to_3d","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"v = dup\ncase v.elements.size\nwhen 3\n break\nwhen 2\n v.elements.push(0)\nelse\n return nil\nend\nreturn v\n"}},{"id":"to_a-instance-method","html_id":"to_a-instance-method","name":"to_a","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L744","def":{"name":"to_a","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Array(Float64).new(size) do |i|\n self[i]\nend"}},{"id":"to_diagonal_matrix-instance-method","html_id":"to_diagonal_matrix-instance-method","name":"to_diagonal_matrix","doc":"Returns a diagonal `Matrix` with the vectors elements as its\ndiagonal elements.","summary":"

Returns a diagonal Matrix with the vectors elements as its diagonal elements.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L607","def":{"name":"to_diagonal_matrix","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix::Diagonal.new(elements)"}},{"id":"to_s(io)-instance-method","html_id":"to_s(io)-instance-method","name":"to_s","doc":null,"summary":null,"abstract":false,"args":[{"name":"io","doc":null,"default_value":"","external_name":"io","restriction":""}],"args_string":"(io)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L748","def":{"name":"to_s","args":[{"name":"io","doc":null,"default_value":"","external_name":"io","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"io << \"{\"\njoin(\", \", io, &.inspect(io))\nio << \"}\"\n"}},{"id":"to_unit_vector-instance-method","html_id":"to_unit_vector-instance-method","name":"to_unit_vector","doc":"Returns a new vector created by normalizing this one\nto have a magnitude of `1`. If the vector is a zero\nvector, it will not be modified.","summary":"

Returns a new vector created by normalizing this one to have a magnitude of 1.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L433","def":{"name":"to_unit_vector","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"r = magnitude\nr == 0 ? dup : map do |x|\n x.to_f64 / r\nend\n"}},{"id":"to_unsafe:Pointer(Float64)-instance-method","html_id":"to_unsafe:Pointer(Float64)-instance-method","name":"to_unsafe","doc":"Returns a pointer to the internal buffer where `self`'s elements are stored.\n\nThis method is **unsafe** because it returns a pointer, and the pointed might eventually\nnot be that of `self` if the array grows and its internal buffer is reallocated.\n\n```\nvec = Vector{1.0, 2.0, 3.0}\nvec.to_unsafe[0] # => 1.0\n```","summary":"

Returns a pointer to the internal buffer where self's elements are stored.

","abstract":false,"args":[],"args_string":" : Pointer(Float64)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L772","def":{"name":"to_unsafe","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Pointer(Float64)","visibility":"Public","body":"@buffer"}},{"id":"top(n)-instance-method","html_id":"top(n)-instance-method","name":"top","doc":"Returns a vector containing only the first `n` elements.","summary":"

Returns a vector containing only the first n elements.

","abstract":false,"args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"args_string":"(n)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L548","def":{"name":"top","args":[{"name":"n","doc":null,"default_value":"","external_name":"n","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"elements = [] of Float64\neach_with_index do |e, i|\n if i < n\n elements << e\n end\nend\nVector.create(elements)\n"}},{"id":"transpose-instance-method","html_id":"transpose-instance-method","name":"transpose","doc":"Transpose this vector into a 1xn `Matrix`","summary":"

Transpose this vector into a 1xn Matrix

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L617","def":{"name":"transpose","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Matrix.col_vector(self)"}},{"id":"unsafe_fetch(index:Int)-instance-method","html_id":"unsafe_fetch(index:Int)-instance-method","name":"unsafe_fetch","doc":null,"summary":null,"abstract":false,"args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"}],"args_string":"(index : Int)","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L759","def":{"name":"unsafe_fetch","args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@buffer[index]"}},{"id":"zero?-instance-method","html_id":"zero?-instance-method","name":"zero?","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/linear_algebra/vector.cr#L788","def":{"name":"zero?","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"all?(&.zero?)"}}],"macros":[],"types":[]}]}]},{"html_id":"github.com/watzon/apatite/Array","path":"Array.html","kind":"class","full_name":"Array(T)","name":"Array","abstract":false,"superclass":{"html_id":"github.com/watzon/apatite/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"github.com/watzon/apatite/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"github.com/watzon/apatite/Indexable","kind":"module","full_name":"Indexable","name":"Indexable"},{"html_id":"github.com/watzon/apatite/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"github.com/watzon/apatite/Iterable","kind":"module","full_name":"Iterable","name":"Iterable"},{"html_id":"github.com/watzon/apatite/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"github.com/watzon/apatite/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"apatite/core_ext/array.cr","line_number":1,"url":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/core_ext/array.cr"}],"repository_name":"github.com/watzon/apatite","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[{"html_id":"github.com/watzon/apatite/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"github.com/watzon/apatite/Indexable","kind":"module","full_name":"Indexable","name":"Indexable"}],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":null,"doc":"An `Array` is an ordered, integer-indexed collection of objects of type T.\n\nArray indexing starts at 0. A negative index is assumed to be\nrelative to the end of the array: -1 indicates the last element,\n-2 is the next to last element, and so on.\n\nAn `Array` can be created using the usual `new` method (several are provided), or with an array literal:\n\n```\nArray(Int32).new # => []\n[1, 2, 3] # Array(Int32)\n[1, \"hello\", 'x'] # Array(Int32 | String | Char)\n```\n\nAn `Array` can have mixed types, meaning T will be a union of types, but these are determined\nwhen the array is created, either by specifying T or by using an array literal. In the latter\ncase, T will be set to the union of the array literal elements' types.\n\nWhen creating an empty array you must always specify T:\n\n```\n[] of Int32 # same as Array(Int32)\n[] # syntax error\n```\n\nAn `Array` is implemented using an internal buffer of some capacity\nand is reallocated when elements are pushed to it when more capacity\nis needed. This is normally known as a [dynamic array](http://en.wikipedia.org/wiki/Dynamic_array).\n\nYou can use a special array literal syntax with other types too, as long as they define an argless\n`new` method and a `<<` method. `Set` is one such type:\n\n```\nset = Set{1, 2, 3} # => Set{1, 2, 3}\nset.class # => Set(Int32)\n```\n\nThe above is the same as this:\n\n```\nset = Set(typeof(1, 2, 3)).new\nset << 1\nset << 2\nset << 3\n```","summary":"

An Array is an ordered, integer-indexed collection of objects of type T.

","class_methods":[],"constructors":[],"instance_methods":[{"id":"all?-instance-method","html_id":"all?-instance-method","name":"all?","doc":"Tests whether all elements evaluate to true","summary":"

Tests whether all elements evaluate to true

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/core_ext/array.cr#L3","def":{"name":"all?","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"each do |i|\n if (!(!i)) == false\n return false\n end\nend\ntrue\n"}},{"id":"any?-instance-method","html_id":"any?-instance-method","name":"any?","doc":"Tests whether any of the elements evaluate to true","summary":"

Tests whether any of the elements evaluate to true

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/core_ext/array.cr#L11","def":{"name":"any?","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"each do |i|\n if (!(!i)) == true\n return true\n end\nend\nfalse\n"}},{"id":"shape-instance-method","html_id":"shape-instance-method","name":"shape","doc":"Get the array's dimensions","summary":"

Get the array's dimensions

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/core_ext/array.cr#L19","def":{"name":"shape","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"max = max_by do |i|\n i.is_a?(Array) ? i.size : i\nend\nmax.is_a?(Array) ? [size, max.size] : [max]\n"}},{"id":"to_vec-instance-method","html_id":"to_vec-instance-method","name":"to_vec","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/watzon/apatite/blob/49a30afcc07bc5354f335c6a6fb5244ed514b63b/src/apatite/core_ext/array.cr#L24","def":{"name":"to_vec","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Apatite::Vector.create(self)"}}],"macros":[],"types":[]}]}}) \ No newline at end of file