You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by av...@apache.org on 2017/04/14 15:51:11 UTC

[12/13] ignite git commit: IGNITE-4572 Machine Learning: Develop distributed algebra support for dense and sparse data sets.

http://git-wip-us.apache.org/repos/asf/ignite/blob/acd21fb8/examples/src/main/java8/org/apache/ignite/examples/java8/math/vector/VectorCustomStorageExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java8/org/apache/ignite/examples/java8/math/vector/VectorCustomStorageExample.java b/examples/src/main/java8/org/apache/ignite/examples/java8/math/vector/VectorCustomStorageExample.java
new file mode 100644
index 0000000..b2778c5
--- /dev/null
+++ b/examples/src/main/java8/org/apache/ignite/examples/java8/math/vector/VectorCustomStorageExample.java
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.examples.java8.math.vector;
+
+import java.util.Arrays;
+import org.apache.ignite.math.Matrix;
+import org.apache.ignite.math.Vector;
+import org.apache.ignite.math.VectorStorage;
+import org.apache.ignite.math.impls.matrix.DenseLocalOnHeapMatrix;
+import org.apache.ignite.math.impls.vector.AbstractVector;
+
+/**
+ * This example shows how to use {@link Vector} based on custom {@link VectorStorage}.
+ */
+public final class VectorCustomStorageExample {
+    /**
+     * Executes example.
+     *
+     * @param args Command line arguments, none required.
+     */
+    public static void main(String[] args) {
+        System.out.println();
+        System.out.println(">>> Vector custom storage API usage example started.");
+
+        System.out.println("\n>>> Creating perpendicular vectors.");
+        double[] data1 = new double[] {1, 0, 3, 0, 5, 0};
+        double[] data2 = new double[] {0, 2, 0, 4, 0, 6};
+
+        Vector v1 = new VectorCustomStorage(data1);
+        Vector v2 = new VectorCustomStorage(data2);
+
+        System.out.println(">>> First vector: " + Arrays.toString(data1));
+        System.out.println(">>> Second vector: " + Arrays.toString(data2));
+
+        double dotProduct = v1.dot(v2);
+        boolean dotProductIsAsExp = dotProduct == 0;
+
+        System.out.println("\n>>> Dot product of vectors: [" + dotProduct
+            + "], it is 0 as expected: [" + dotProductIsAsExp + "].");
+
+        assert dotProductIsAsExp : "Expect dot product of perpendicular vectors to be 0.";
+
+        Vector hypotenuse = v1.plus(v2);
+
+        System.out.println("\n>>> Hypotenuse (sum of vectors): " + Arrays.toString(hypotenuse.getStorage().data()));
+
+        double lenSquared1 = v1.getLengthSquared();
+        double lenSquared2 = v2.getLengthSquared();
+        double lenSquaredHypotenuse = hypotenuse.getLengthSquared();
+
+        boolean lenSquaredHypotenuseIsAsExp = lenSquaredHypotenuse == lenSquared1 + lenSquared2;
+
+        System.out.println(">>> Squared length of first vector: [" + lenSquared1 + "].");
+        System.out.println(">>> Squared length of second vector: [" + lenSquared2 + "].");
+        System.out.println(">>> Squared length of hypotenuse: [" + lenSquaredHypotenuse
+            + "], equals sum of squared lengths of two original vectors as expected: ["
+            + lenSquaredHypotenuseIsAsExp + "].");
+
+        assert lenSquaredHypotenuseIsAsExp : "Expect squared length of hypotenuse to be as per Pythagorean theorem.";
+
+        System.out.println("\n>>> Vector custom storage API usage example completed.");
+    }
+
+    /**
+     * Example of vector with custom storage, modeled after
+     * {@link org.apache.ignite.math.impls.vector.DenseLocalOnHeapVector}.
+     */
+    static class VectorCustomStorage extends AbstractVector {
+        /**
+         * @param arr Source array.
+         * @param cp {@code true} to clone array, reuse it otherwise.
+         */
+        private VectorStorage mkStorage(double[] arr, boolean cp) {
+            assert arr != null;
+
+            return new ExampleVectorStorage(cp ? arr.clone() : arr);
+        }
+
+        /** */
+        public VectorCustomStorage() {
+            // No-op.
+        }
+
+        /**
+         * @param arr Source array.
+         * @param shallowCp {@code true} to use shallow copy.
+         */
+        VectorCustomStorage(double[] arr, boolean shallowCp) {
+            setStorage(mkStorage(arr, shallowCp));
+        }
+
+        /**
+         * @param arr Source array.
+         */
+        VectorCustomStorage(double[] arr) {
+            this(arr, false);
+        }
+
+        /** {@inheritDoc} */
+        @Override public Matrix likeMatrix(int rows, int cols) {
+            return new DenseLocalOnHeapMatrix(rows, cols);
+        }
+
+        /** {@inheritDoc */
+        @Override public Vector like(int crd) {
+            return new org.apache.ignite.math.impls.vector.DenseLocalOnHeapVector(crd);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/acd21fb8/examples/src/main/java8/org/apache/ignite/examples/java8/math/vector/VectorExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java8/org/apache/ignite/examples/java8/math/vector/VectorExample.java b/examples/src/main/java8/org/apache/ignite/examples/java8/math/vector/VectorExample.java
new file mode 100644
index 0000000..f852f0a
--- /dev/null
+++ b/examples/src/main/java8/org/apache/ignite/examples/java8/math/vector/VectorExample.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.examples.java8.math.vector;
+
+import java.util.Arrays;
+import org.apache.ignite.math.Vector;
+import org.apache.ignite.math.impls.vector.DenseLocalOnHeapVector;
+
+/**
+ * This example shows how to use {@link Vector} API.
+ */
+public final class VectorExample {
+    /**
+     * Executes example.
+     *
+     * @param args Command line arguments, none required.
+     */
+    public static void main(String[] args) {
+        System.out.println();
+        System.out.println(">>> Basic Vector API usage example started.");
+
+        System.out.println("\n>>> Creating perpendicular vectors.");
+        double[] data1 = new double[] {1, 0, 3, 0, 5, 0};
+        double[] data2 = new double[] {0, 2, 0, 4, 0, 6};
+
+        Vector v1 = new DenseLocalOnHeapVector(data1);
+        Vector v2 = new DenseLocalOnHeapVector(data2);
+
+        System.out.println(">>> First vector: " + Arrays.toString(data1));
+        System.out.println(">>> Second vector: " + Arrays.toString(data2));
+
+        double dotProduct = v1.dot(v2);
+        boolean dotProductIsAsExp = dotProduct == 0;
+
+        System.out.println("\n>>> Dot product of vectors: [" + dotProduct
+            + "], it is 0 as expected: [" + dotProductIsAsExp + "].");
+
+        assert dotProductIsAsExp : "Expect dot product of perpendicular vectors to be 0.";
+
+        Vector hypotenuse = v1.plus(v2);
+
+        System.out.println("\n>>> Hypotenuse (sum of vectors): " + Arrays.toString(hypotenuse.getStorage().data()));
+
+        double lenSquared1 = v1.getLengthSquared();
+        double lenSquared2 = v2.getLengthSquared();
+        double lenSquaredHypotenuse = hypotenuse.getLengthSquared();
+
+        boolean lenSquaredHypotenuseIsAsExp = lenSquaredHypotenuse == lenSquared1 + lenSquared2;
+
+        System.out.println(">>> Squared length of first vector: [" + lenSquared1 + "].");
+        System.out.println(">>> Squared length of second vector: [" + lenSquared2 + "].");
+        System.out.println(">>> Squared length of hypotenuse: [" + lenSquaredHypotenuse
+            + "], equals sum of squared lengths of two original vectors as expected: ["
+            + lenSquaredHypotenuseIsAsExp + "].");
+
+        assert lenSquaredHypotenuseIsAsExp : "Expect squared length of hypotenuse to be as per Pythagorean theorem.";
+
+        System.out.println("\n>>> Basic Vector API usage example completed.");
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/acd21fb8/examples/src/main/java8/org/apache/ignite/examples/java8/math/vector/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java8/org/apache/ignite/examples/java8/math/vector/package-info.java b/examples/src/main/java8/org/apache/ignite/examples/java8/math/vector/package-info.java
new file mode 100644
index 0000000..ff09e4e
--- /dev/null
+++ b/examples/src/main/java8/org/apache/ignite/examples/java8/math/vector/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * <!-- Package description. -->
+ * Core algebra vector examples.
+ */
+package org.apache.ignite.examples.java8.math.vector;

http://git-wip-us.apache.org/repos/asf/ignite/blob/acd21fb8/modules/math/README.txt
----------------------------------------------------------------------
diff --git a/modules/math/README.txt b/modules/math/README.txt
new file mode 100644
index 0000000..a48da21
--- /dev/null
+++ b/modules/math/README.txt
@@ -0,0 +1,15 @@
+Apache Ignite Math Module
+------------------------------
+
+Apache Ignite Math module provides several implementations of vector and matrices.
+
+Module includes on heap and off heap, dense and sparse, local and distributed implementations.
+
+Based on ideas from Apache Mahout.
+
+# Local build with javadoc
+
+Run from project root:
+mvn clean package -Pmath -DskipTests -pl modules/math -am
+
+Find generated jars in target folder.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/acd21fb8/modules/math/licenses/apache-2.0.txt
----------------------------------------------------------------------
diff --git a/modules/math/licenses/apache-2.0.txt b/modules/math/licenses/apache-2.0.txt
new file mode 100644
index 0000000..d645695
--- /dev/null
+++ b/modules/math/licenses/apache-2.0.txt
@@ -0,0 +1,202 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.

http://git-wip-us.apache.org/repos/asf/ignite/blob/acd21fb8/modules/math/licenses/mit.txt
----------------------------------------------------------------------
diff --git a/modules/math/licenses/mit.txt b/modules/math/licenses/mit.txt
new file mode 100644
index 0000000..00217dc
--- /dev/null
+++ b/modules/math/licenses/mit.txt
@@ -0,0 +1,7 @@
+Copyright <YEAR> <COPYRIGHT HOLDER>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/acd21fb8/modules/math/pom.xml
----------------------------------------------------------------------
diff --git a/modules/math/pom.xml b/modules/math/pom.xml
new file mode 100644
index 0000000..d3b284e
--- /dev/null
+++ b/modules/math/pom.xml
@@ -0,0 +1,109 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<!--
+    POM file.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <artifactId>ignite-parent</artifactId>
+        <groupId>org.apache.ignite</groupId>
+        <version>1</version>
+        <relativePath>../../parent</relativePath>
+    </parent>
+
+    <artifactId>ignite-math</artifactId>
+    <version>2.0.0-SNAPSHOT</version>
+    <url>http://ignite.apache.org</url>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.ignite</groupId>
+            <artifactId>ignite-core</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.ignite</groupId>
+            <artifactId>ignite-core</artifactId>
+            <version>${project.version}</version>
+            <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>it.unimi.dsi</groupId>
+            <artifactId>fastutil</artifactId>
+            <version>7.0.12</version>
+        </dependency>
+
+        <dependency>
+            <!-- IMPL NOTE this is to write math benchmarks results, IGN-6530 -->
+            <groupId>com.dropbox.core</groupId>
+            <artifactId>dropbox-core-sdk</artifactId>
+            <version>2.1.1</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>log4j</groupId>
+            <artifactId>log4j</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-beans</artifactId>
+            <version>${spring.version}</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-context</artifactId>
+            <version>${spring.version}</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <source>1.8</source>
+                    <target>1.8</target>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+    <profiles>
+        <profile>
+            <id>math</id>
+        </profile>
+    </profiles>
+</project>

http://git-wip-us.apache.org/repos/asf/ignite/blob/acd21fb8/modules/math/src/main/java/org/apache/ignite/math/Algebra.java
----------------------------------------------------------------------
diff --git a/modules/math/src/main/java/org/apache/ignite/math/Algebra.java b/modules/math/src/main/java/org/apache/ignite/math/Algebra.java
new file mode 100644
index 0000000..6bfd608
--- /dev/null
+++ b/modules/math/src/main/java/org/apache/ignite/math/Algebra.java
@@ -0,0 +1,571 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+Copyright 1999 CERN - European Organization for Nuclear Research.
+Permission to use, copy, modify, distribute and sell this software and its documentation for any purpose
+is hereby granted without fee, provided that the above copyright notice appear in all copies and
+that both that copyright notice and this permission notice appear in supporting documentation.
+CERN makes no representations about the suitability of this software for any purpose.
+It is provided "as is" without expressed or implied warranty.
+*/
+
+package org.apache.ignite.math;
+
+/**
+ * Miscellaneous arithmetic and algebra functions.
+ * Lifted from Apache Mahout.
+ */
+public class Algebra extends Constants {
+    /** */ private static final double[] STIRLING_CORRECTION = {
+        0.0,
+        8.106146679532726e-02, 4.134069595540929e-02,
+        2.767792568499834e-02, 2.079067210376509e-02,
+        1.664469118982119e-02, 1.387612882307075e-02,
+        1.189670994589177e-02, 1.041126526197209e-02,
+        9.255462182712733e-03, 8.330563433362871e-03,
+        7.573675487951841e-03, 6.942840107209530e-03,
+        6.408994188004207e-03, 5.951370112758848e-03,
+        5.554733551962801e-03, 5.207655919609640e-03,
+        4.901395948434738e-03, 4.629153749334029e-03,
+        4.385560249232324e-03, 4.166319691996922e-03,
+        3.967954218640860e-03, 3.787618068444430e-03,
+        3.622960224683090e-03, 3.472021382978770e-03,
+        3.333155636728090e-03, 3.204970228055040e-03,
+        3.086278682608780e-03, 2.976063983550410e-03,
+        2.873449362352470e-03, 2.777674929752690e-03,
+    };
+
+    /** */ private static final double[] LOG_FACTORIALS = {
+        0.00000000000000000, 0.00000000000000000, 0.69314718055994531,
+        1.79175946922805500, 3.17805383034794562, 4.78749174278204599,
+        6.57925121201010100, 8.52516136106541430, 10.60460290274525023,
+        12.80182748008146961, 15.10441257307551530, 17.50230784587388584,
+        19.98721449566188615, 22.55216385312342289, 25.19122118273868150,
+        27.89927138384089157, 30.67186010608067280, 33.50507345013688888,
+        36.39544520803305358, 39.33988418719949404, 42.33561646075348503,
+        45.38013889847690803, 48.47118135183522388, 51.60667556776437357,
+        54.78472939811231919, 58.00360522298051994, 61.26170176100200198,
+        64.55753862700633106, 67.88974313718153498, 71.25703896716800901
+    };
+
+    /** */ private static final long[] LONG_FACTORIALS = {
+        1L,
+        1L,
+        2L,
+        6L,
+        24L,
+        120L,
+        720L,
+        5040L,
+        40320L,
+        362880L,
+        3628800L,
+        39916800L,
+        479001600L,
+        6227020800L,
+        87178291200L,
+        1307674368000L,
+        20922789888000L,
+        355687428096000L,
+        6402373705728000L,
+        121645100408832000L,
+        2432902008176640000L
+    };
+
+    /** */ private static final double[] DOUBLE_FACTORIALS = {
+        5.109094217170944E19,
+        1.1240007277776077E21,
+        2.585201673888498E22,
+        6.204484017332394E23,
+        1.5511210043330984E25,
+        4.032914611266057E26,
+        1.0888869450418352E28,
+        3.048883446117138E29,
+        8.841761993739701E30,
+        2.652528598121911E32,
+        8.222838654177924E33,
+        2.6313083693369355E35,
+        8.68331761881189E36,
+        2.952327990396041E38,
+        1.0333147966386144E40,
+        3.719933267899013E41,
+        1.3763753091226346E43,
+        5.23022617466601E44,
+        2.0397882081197447E46,
+        8.15915283247898E47,
+        3.34525266131638E49,
+        1.4050061177528801E51,
+        6.041526306337384E52,
+        2.6582715747884495E54,
+        1.196222208654802E56,
+        5.502622159812089E57,
+        2.5862324151116827E59,
+        1.2413915592536068E61,
+        6.082818640342679E62,
+        3.0414093201713376E64,
+        1.5511187532873816E66,
+        8.06581751709439E67,
+        4.274883284060024E69,
+        2.308436973392413E71,
+        1.2696403353658264E73,
+        7.109985878048632E74,
+        4.052691950487723E76,
+        2.350561331282879E78,
+        1.386831185456898E80,
+        8.32098711274139E81,
+        5.075802138772246E83,
+        3.146997326038794E85,
+        1.9826083154044396E87,
+        1.2688693218588414E89,
+        8.247650592082472E90,
+        5.443449390774432E92,
+        3.6471110918188705E94,
+        2.48003554243683E96,
+        1.7112245242814127E98,
+        1.1978571669969892E100,
+        8.504785885678624E101,
+        6.123445837688612E103,
+        4.470115461512686E105,
+        3.307885441519387E107,
+        2.4809140811395404E109,
+        1.8854947016660506E111,
+        1.451830920282859E113,
+        1.1324281178206295E115,
+        8.94618213078298E116,
+        7.15694570462638E118,
+        5.797126020747369E120,
+        4.7536433370128435E122,
+        3.94552396972066E124,
+        3.314240134565354E126,
+        2.8171041143805494E128,
+        2.4227095383672744E130,
+        2.107757298379527E132,
+        1.854826422573984E134,
+        1.6507955160908465E136,
+        1.4857159644817605E138,
+        1.3520015276784033E140,
+        1.2438414054641305E142,
+        1.156772507081641E144,
+        1.0873661566567426E146,
+        1.0329978488239061E148,
+        9.916779348709491E149,
+        9.619275968248216E151,
+        9.426890448883248E153,
+        9.332621544394415E155,
+        9.332621544394418E157,
+        9.42594775983836E159,
+        9.614466715035125E161,
+        9.902900716486178E163,
+        1.0299016745145631E166,
+        1.0813967582402912E168,
+        1.1462805637347086E170,
+        1.2265202031961373E172,
+        1.324641819451829E174,
+        1.4438595832024942E176,
+        1.5882455415227423E178,
+        1.7629525510902457E180,
+        1.974506857221075E182,
+        2.2311927486598138E184,
+        2.543559733472186E186,
+        2.925093693493014E188,
+        3.393108684451899E190,
+        3.96993716080872E192,
+        4.6845258497542896E194,
+        5.574585761207606E196,
+        6.689502913449135E198,
+        8.094298525273444E200,
+        9.875044200833601E202,
+        1.2146304367025332E205,
+        1.506141741511141E207,
+        1.882677176888926E209,
+        2.3721732428800483E211,
+        3.0126600184576624E213,
+        3.856204823625808E215,
+        4.974504222477287E217,
+        6.466855489220473E219,
+        8.471580690878813E221,
+        1.1182486511960037E224,
+        1.4872707060906847E226,
+        1.99294274616152E228,
+        2.690472707318049E230,
+        3.6590428819525483E232,
+        5.0128887482749884E234,
+        6.917786472619482E236,
+        9.615723196941089E238,
+        1.3462012475717523E241,
+        1.8981437590761713E243,
+        2.6953641378881633E245,
+        3.8543707171800694E247,
+        5.550293832739308E249,
+        8.047926057471989E251,
+        1.1749972043909107E254,
+        1.72724589045464E256,
+        2.5563239178728637E258,
+        3.8089226376305687E260,
+        5.7133839564458575E262,
+        8.627209774233244E264,
+        1.3113358856834527E267,
+        2.0063439050956838E269,
+        3.0897696138473515E271,
+        4.789142901463393E273,
+        7.471062926282892E275,
+        1.1729568794264134E278,
+        1.8532718694937346E280,
+        2.946702272495036E282,
+        4.714723635992061E284,
+        7.590705053947223E286,
+        1.2296942187394494E289,
+        2.0044015765453032E291,
+        3.287218585534299E293,
+        5.423910666131583E295,
+        9.003691705778434E297,
+        1.5036165148649983E300,
+        2.5260757449731988E302,
+        4.2690680090047056E304,
+        7.257415615308004E306
+    };
+
+    /**
+     * Efficiently returns the binomial coefficient, often also referred to as
+     * "n over k" or "n choose k". The binomial coefficient is defined as
+     * {@code (n * n-1 * ... * n-k+1 ) / ( 1 * 2 * ... * k )}.
+     * <ul> <li>{@code k&lt;0}: {@code 0}.</li>
+     * <li>{@code k==0}: {@code 1}.</li>
+     * <li>{@code k==1}: {@code n}.</li>
+     * <li>else: {@code (n * n-1 * ... * n-k+1 ) / ( 1 * 2 * ... * k)}.</li>
+     * </ul>
+     *
+     * @param n
+     * @param k
+     * @return Binomial coefficient.
+     */
+    public static double binomial(double n, long k) {
+        if (k < 0)
+            return 0;
+
+        if (k == 0)
+            return 1;
+
+        if (k == 1)
+            return n;
+
+        // binomial(n,k) = (n * n-1 * ... * n-k+1 ) / ( 1 * 2 * ... * k )
+        double a = n - k + 1;
+        double b = 1;
+        double binomial = 1;
+
+        for (long i = k; i-- > 0; )
+            binomial *= (a++) / (b++);
+
+        return binomial;
+    }
+
+    /**
+     * Efficiently returns the binomial coefficient, often also referred to as "n over k" or "n choose k".
+     * The binomial coefficient is defined as
+     * <ul> <li>{@code k&lt;0}: {@code 0}. <li>{@code k==0 || k==n}: {@code 1}. <li>{@code k==1 || k==n-1}:
+     * {@code n}. <li>else: {@code (n * n-1 * ... * n-k+1 ) / ( 1 * 2 * ... * k )}. </ul>
+     *
+     * @param n
+     * @param k
+     * @return Binomial coefficient.
+     */
+    public static double binomial(long n, long k) {
+        if (k < 0)
+            return 0;
+
+        if (k == 0 || k == n)
+            return 1;
+
+        if (k == 1 || k == n - 1)
+            return n;
+
+        if (n > k) {
+            int max = LONG_FACTORIALS.length + DOUBLE_FACTORIALS.length;
+
+            if (n < max) {
+                double nFac = factorial((int)n);
+                double kFac = factorial((int)k);
+                double nMinusKFac = factorial((int)(n - k));
+                double nk = nMinusKFac * kFac;
+
+                if (nk != Double.POSITIVE_INFINITY) // No numeric overflow?
+                    return nFac / nk;
+            }
+
+            if (k > n / 2)
+                k = n - k;
+        }
+
+        // binomial(n,k) = (n * n-1 * ... * n-k+1 ) / ( 1 * 2 * ... * k )
+        long a = n - k + 1;
+        long b = 1;
+        double binomial = 1;
+
+        for (long i = k; i-- > 0; )
+            binomial *= (double)a++ / (b++);
+
+        return binomial;
+    }
+
+    /**
+     * Returns the smallest <code>long &gt;= value</code>.
+     * <dl><dt>Examples: {@code 1.0 -> 1, 1.2 -> 2, 1.9 -> 2}. This
+     * method is safer than using (long) Math.ceil(value), because of possible rounding error.</dt></dl>
+     *
+     * @param val
+     */
+    public static long ceil(double val) {
+        return Math.round(Math.ceil(val));
+    }
+
+    /**
+     * Evaluates the series of Chebyshev polynomials Ti at argument x/2. The series is given by
+     * <pre>
+     *        N-1
+     *         - '
+     *  y  =   &gt;   coef[i] T (x/2)
+     *         -            i
+     *        i=0
+     * </pre>
+     * Coefficients are stored in reverse order, i.e. the zero order term is last in the array.  Note N is the number of
+     * coefficients, not the order. <p> If coefficients are for the interval a to b, x must have been transformed to x
+     * -&lt; 2(2x - b - a)/(b-a) before entering the routine.  This maps x from (a, b) to (-1, 1), over which the
+     * Chebyshev polynomials are defined. <p> If the coefficients are for the inverted interval, in which (a, b) is
+     * mapped to (1/b, 1/a), the transformation required is {@code x -> 2(2ab/x - b - a)/(b-a)}.  If b is infinity, this
+     * becomes {@code x -> 4a/x - 1}. <p> SPEED: <p> Taking advantage of the recurrence properties of the Chebyshev
+     * polynomials, the routine requires one more addition per loop than evaluating a nested polynomial of the same
+     * degree.
+     *
+     * @param x Argument to the polynomial.
+     * @param coef Coefficients of the polynomial.
+     * @param N Number of coefficients.
+     */
+    public static double chbevl(double x, double[] coef, int N) {
+        int p = 0;
+
+        double b0 = coef[p++];
+        double b1 = 0.0;
+        int i = N - 1;
+
+        double b2;
+
+        do {
+            b2 = b1;
+            b1 = b0;
+            b0 = x * b1 - b2 + coef[p++];
+        }
+        while (--i > 0);
+
+        return 0.5 * (b0 - b2);
+    }
+
+    /**
+     * Instantly returns the factorial {@code k!}.
+     *
+     * @param k must hold {@code k &gt;= 0}.
+     */
+    private static double factorial(int k) {
+        if (k < 0)
+            throw new IllegalArgumentException();
+
+        int len1 = LONG_FACTORIALS.length;
+
+        if (k < len1)
+            return LONG_FACTORIALS[k];
+
+        int len2 = DOUBLE_FACTORIALS.length;
+
+        return (k < len1 + len2) ? DOUBLE_FACTORIALS[k - len1] : Double.POSITIVE_INFINITY;
+    }
+
+    /**
+     * Returns the largest <code>long &lt;= value</code>.
+     * <dl><dt>Examples: {@code 1.0 -> 1, 1.2 -> 1, 1.9 -> 1 <dt> 2.0 -> 2, 2.2 -> 2, 2.9 -> 2}</dt></dl>
+     * This method is safer than using (long) Math.floor(value), because of possible rounding error.
+     */
+    public static long floor(double val) {
+        return Math.round(Math.floor(val));
+    }
+
+    /**
+     * Returns {@code log<sub>base</sub>value}.
+     */
+    public static double log(double base, double val) {
+        return Math.log(val) / Math.log(base);
+    }
+
+    /**
+     * Returns {@code log<sub>10</sub>value}.
+     */
+    public static double log10(double val) {
+        // 1.0 / Math.log(10) == 0.43429448190325176
+        return Math.log(val) * 0.43429448190325176;
+    }
+
+    /**
+     * Returns {@code log<sub>2</sub>value}.
+     */
+    public static double log2(double val) {
+        // 1.0 / Math.log(2) == 1.4426950408889634
+        return Math.log(val) * 1.4426950408889634;
+    }
+
+    /**
+     * Returns {@code log(k!)}. Tries to avoid overflows. For {@code k&lt;30} simply looks up a table in O(1).
+     * For {@code k&gt;=30} uses stirlings approximation.
+     *
+     * @param k must hold {@code k &gt;= 0}.
+     */
+    public static double logFactorial(int k) {
+        if (k >= 30) {
+            double r = 1.0 / k;
+            double rr = r * r;
+            double C7 = -5.95238095238095238e-04;
+            double C5 = 7.93650793650793651e-04;
+            double C3 = -2.77777777777777778e-03;
+            double C1 = 8.33333333333333333e-02;
+            double C0 = 9.18938533204672742e-01;
+
+            return (k + 0.5) * Math.log(k) - k + C0 + r * (C1 + rr * (C3 + rr * (C5 + rr * C7)));
+        }
+        else
+            return LOG_FACTORIALS[k];
+    }
+
+    /**
+     * Instantly returns the factorial {@code k!}.
+     *
+     * @param k must hold {@code k >= 0 && k < 21}
+     */
+    public static long longFactorial(int k) {
+        if (k < 0)
+            throw new IllegalArgumentException("Negative k");
+
+        if (k < LONG_FACTORIALS.length)
+            return LONG_FACTORIALS[k];
+
+        throw new IllegalArgumentException("Overflow");
+    }
+
+    /**
+     * Returns the StirlingCorrection.
+     *
+     * Correction term of the Stirling approximation for {@code log(k!)} (series in
+     * 1/k, or table values for small k) with int parameter k. </p> {@code  log k! = (k + 1/2)log(k + 1) - (k + 1) +
+     * (1/2)log(2Pi) + STIRLING_CORRECTION(k + 1) log k! = (k + 1/2)log(k)     -  k      + (1/2)log(2Pi) +
+     * STIRLING_CORRECTION(k) }
+     */
+    public static double stirlingCorrection(int k) {
+        if (k > 30) {
+            double r = 1.0 / k;
+            double rr = r * r;
+            double C7 = -5.95238095238095238e-04;
+            double C5 = 7.93650793650793651e-04;
+            double C3 = -2.77777777777777778e-03;
+            double C1 = 8.33333333333333333e-02;
+
+            return r * (C1 + rr * (C3 + rr * (C5 + rr * C7)));
+        }
+        else
+            return STIRLING_CORRECTION[k];
+    }
+
+    /**
+     * Evaluates the given polynomial of degree {@code N} at {@code x}, assuming coefficient of N is 1.0. Otherwise same
+     * as {@link #evalPoly(double, double[], int)}.
+     * <pre>
+     *                     2          N
+     * y  =  C  + C x + C x  +...+ C x
+     *        0    1     2          N
+     *
+     * where C  = 1 and hence is omitted from the array.
+     *        N
+     *
+     * Coefficients are stored in reverse order:
+     *
+     * coef[0] = C  , ..., coef[N-1] = C  .
+     *            N-1                   0
+     *
+     * Calling arguments are otherwise the same as {@link #evalPoly(double, double[], int)}.
+     * </pre>
+     * In the interest of speed, there are no checks for out of bounds arithmetic.
+     *
+     * @param x Argument to the polynomial.
+     * @param coef Coefficients of the polynomial.
+     * @param n Degree of the polynomial.
+     */
+    public static double evalPoly1(double x, double[] coef, int n) {
+        double res = x + coef[0];
+
+        for (int i = 1; i < n; i++)
+            res = res * x + coef[i];
+
+        return res;
+    }
+
+    /**
+     * Evaluates the given polynomial of degree {@code N} at {@code x}.
+     * <pre>
+     *                     2          N
+     * y  =  C  + C x + C x  +...+ C x
+     *        0    1     2          N
+     *
+     * Coefficients are stored in reverse order:
+     *
+     * coef[0] = C  , ..., coef[N] = C  .
+     *            N                   0
+     * </pre>
+     * In the interest of speed, there are no checks for out of bounds arithmetic.
+     *
+     * @param x Argument to the polynomial.
+     * @param coef Coefficients of the polynomial.
+     * @param n Degree of the polynomial.
+     */
+    public static double evalPoly(double x, double[] coef, int n) {
+        double res = coef[0];
+
+        for (int i = 1; i <= n; i++)
+            res = res * x + coef[i];
+
+        return res;
+    }
+
+    /**
+     * Gets <code>sqrt(a^2 + b^2)</code> without under/overflow.
+     *
+     * @param a
+     * @param b
+     */
+    public static double hypot(double a, double b) {
+        double r;
+
+        if (Math.abs(a) > Math.abs(b)) {
+            r = b / a;
+            r = Math.abs(a) * Math.sqrt(1 + r * r);
+        }
+        else if (b != 0) {
+            r = a / b;
+            r = Math.abs(b) * Math.sqrt(1 + r * r);
+        }
+        else
+            r = 0.0;
+
+        return r;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/acd21fb8/modules/math/src/main/java/org/apache/ignite/math/Constants.java
----------------------------------------------------------------------
diff --git a/modules/math/src/main/java/org/apache/ignite/math/Constants.java b/modules/math/src/main/java/org/apache/ignite/math/Constants.java
new file mode 100644
index 0000000..02756b6
--- /dev/null
+++ b/modules/math/src/main/java/org/apache/ignite/math/Constants.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+Copyright 1999 CERN - European Organization for Nuclear Research.
+Permission to use, copy, modify, distribute and sell this software and its documentation for any purpose
+is hereby granted without fee, provided that the above copyright notice appear in all copies and
+that both that copyright notice and this permission notice appear in supporting documentation.
+CERN makes no representations about the suitability of this software for any purpose.
+It is provided "as is" without expressed or implied warranty.
+*/
+
+package org.apache.ignite.math;
+
+/**
+ * Math constants. Lifted from Apache Mahout.
+ */
+public class Constants {
+    /** */ public static final double MACHEP = 1.11022302462515654042E-16;
+    /** */ public static final double MAXLOG = 7.09782712893383996732E2;
+    /** */ public static final double MINLOG = -7.451332191019412076235E2;
+    /** */ public static final double MAXGAM = 171.624376956302725;
+    /** */ public static final double SQTPI = 2.50662827463100050242E0;
+    /** */ public static final double SQRTH = 7.07106781186547524401E-1;
+    /** */ public static final double LOGPI = 1.14472988584940017414;
+    /** */ public static final double BIG = 4.503599627370496e15;
+    /** */ public static final double BIGINV = 2.22044604925031308085e-16;
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/acd21fb8/modules/math/src/main/java/org/apache/ignite/math/Destroyable.java
----------------------------------------------------------------------
diff --git a/modules/math/src/main/java/org/apache/ignite/math/Destroyable.java b/modules/math/src/main/java/org/apache/ignite/math/Destroyable.java
new file mode 100644
index 0000000..f3b467c
--- /dev/null
+++ b/modules/math/src/main/java/org/apache/ignite/math/Destroyable.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.math;
+
+/**
+ * Support for destroying objects that are managed outside of JVM.
+ */
+public interface Destroyable {
+    /**
+     * Destroys object if managed outside of JVM. It's a no-op in all other cases.
+     */
+    public default void destroy() {
+        // No-op.
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/acd21fb8/modules/math/src/main/java/org/apache/ignite/math/IdentityValueMapper.java
----------------------------------------------------------------------
diff --git a/modules/math/src/main/java/org/apache/ignite/math/IdentityValueMapper.java b/modules/math/src/main/java/org/apache/ignite/math/IdentityValueMapper.java
new file mode 100644
index 0000000..65c7024
--- /dev/null
+++ b/modules/math/src/main/java/org/apache/ignite/math/IdentityValueMapper.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.math;
+
+/**
+ * Identity value mapper.
+ */
+public class IdentityValueMapper implements ValueMapper<Double> {
+    /** */ private static final long serialVersionUID = -8010078306142216389L;
+
+    /** {@inheritDoc} */
+    @Override public Double fromDouble(double v) {
+        return v;
+    }
+
+    /** {@inheritDoc} */
+    @Override public double toDouble(Double v) {
+        assert v != null;
+
+        return v;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int hashCode() {
+        return Long.hashCode(serialVersionUID);
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean equals(Object o) {
+        if (this == o)
+            return true;
+
+        if (o == null || getClass() != o.getClass())
+            return false;
+
+        return true;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/acd21fb8/modules/math/src/main/java/org/apache/ignite/math/KeyMapper.java
----------------------------------------------------------------------
diff --git a/modules/math/src/main/java/org/apache/ignite/math/KeyMapper.java b/modules/math/src/main/java/org/apache/ignite/math/KeyMapper.java
new file mode 100644
index 0000000..f4f9a39
--- /dev/null
+++ b/modules/math/src/main/java/org/apache/ignite/math/KeyMapper.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.math;
+
+import java.io.Serializable;
+
+/**
+ * Maps key objects to index in {@link Vector} or {@link Matrix}.
+ */
+public interface KeyMapper<K> extends Serializable {
+    /**
+     * Checks given cache key corresponds to a valid index in vector or matrix.
+     *
+     * @param k Key to check.
+     * @return {@code true} if there is a valid index, {@code false} otherwise.
+     */
+    public boolean isValid(K k);
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/acd21fb8/modules/math/src/main/java/org/apache/ignite/math/Matrix.java
----------------------------------------------------------------------
diff --git a/modules/math/src/main/java/org/apache/ignite/math/Matrix.java b/modules/math/src/main/java/org/apache/ignite/math/Matrix.java
new file mode 100644
index 0000000..ee7a807
--- /dev/null
+++ b/modules/math/src/main/java/org/apache/ignite/math/Matrix.java
@@ -0,0 +1,518 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.math;
+
+import java.io.Externalizable;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.math.exceptions.CardinalityException;
+import org.apache.ignite.math.exceptions.IndexException;
+import org.apache.ignite.math.exceptions.UnsupportedOperationException;
+import org.apache.ignite.math.functions.IgniteBiFunction;
+import org.apache.ignite.math.functions.IgniteDoubleFunction;
+import org.apache.ignite.math.functions.IgniteFunction;
+import org.apache.ignite.math.functions.IntIntToDoubleFunction;
+
+/**
+ * A matrix interface.
+ *
+ * Based on its flavor it can have vastly different implementations tailored for
+ * for different types of data (e.g. dense vs. sparse), different sizes of data or different operation
+ * optimizations.
+ *
+ * Note also that not all operations can be supported by all underlying implementations. If an operation is not
+ * supported a {@link UnsupportedOperationException} is thrown. This exception can also be thrown in partial cases
+ * where an operation is unsupported only in special cases, e.g. where a given operation cannot be deterministically
+ * completed in polynomial time.
+ *
+ * Based on ideas from <a href="http://mahout.apache.org/">Apache Mahout</a>.
+ */
+public interface Matrix extends MetaAttributes, Externalizable, StorageOpsMetrics, Destroyable {
+    /**
+     * Holder for matrix's element.
+     */
+    interface Element {
+        /**
+         * Gets element's value.
+         *
+         * @return The value of this matrix element.
+         */
+        double get();
+
+        /**
+         * Gets element's row index.
+         *
+         * @return The row index of this element.
+         */
+        int row();
+
+        /**
+         * Gets element's column index.
+         *
+         * @return The column index of this element.
+         */
+        int column();
+
+        /**
+         * Sets element's value.
+         *
+         * @param val Value to set.
+         */
+        void set(double val);
+    }
+
+    /**
+     * Gets the maximum value in this matrix.
+     *
+     * @return Maximum value in this matrix.
+     */
+    public double maxValue();
+
+    /**
+     * Gets the minimum value in this matrix.
+     *
+     * @return Minimum value in this matrix.
+     */
+    public double minValue();
+
+    /**
+     * Gets the maximum element in this matrix.
+     *
+     * @return Maximum element in this matrix.
+     */
+    public Element maxElement();
+
+    /**
+     * Gets the minimum element in this matrix.
+     *
+     * @return Minimum element in this matrix.
+     */
+    public Element minElement();
+
+    /**
+     * Gets the matrix's element at the given coordinates.
+     *
+     * @param row Row index.
+     * @param col Column index.
+     * @return Element at the given coordinates.
+     */
+    public Element getElement(int row, int col);
+
+    /**
+     * Swaps two rows in this matrix.
+     *
+     * @param row1 Row #1.
+     * @param row2 Row #2.
+     * @return This matrix.
+     */
+    public Matrix swapRows(int row1, int row2);
+
+    /**
+     * Swaps two columns in this matrix.
+     *
+     * @param col1 Column #1.
+     * @param col2 Column #2.
+     * @return This matrix.
+     */
+    public Matrix swapColumns(int col1, int col2);
+
+    /**
+     * Assigns given value to all elements of this matrix.
+     *
+     * @param val Value to assign to all elements.
+     * @return This matrix.
+     */
+    public Matrix assign(double val);
+
+    /**
+     * Assigns given values to this matrix.
+     *
+     * @param vals Values to assign.
+     * @return This matrix.
+     * @throws CardinalityException Thrown if cardinalities mismatch.
+     */
+    public Matrix assign(double[][] vals);
+
+    /**
+     * Assigns values from given matrix to this matrix.
+     *
+     * @param mtx Matrix to assign to this matrix.
+     * @return This matrix.
+     * @throws CardinalityException Thrown if cardinalities mismatch.
+     */
+    public Matrix assign(Matrix mtx);
+
+    /**
+     * Assigns each matrix element to the value generated by given function.
+     *
+     * @param fun Function that takes the row and column and returns the value to assign.
+     * @return This matrix.
+     */
+    public Matrix assign(IntIntToDoubleFunction fun);
+
+    /**
+     * Maps all values in this matrix through a given function.
+     *
+     * @param fun Mapping function.
+     * @return This matrix.
+     */
+    public Matrix map(IgniteDoubleFunction<Double> fun);
+
+    /**
+     * Maps all values in this matrix through a given function.
+     *
+     * For this matrix <code>A</code>, argument matrix <code>B</code> and the
+     * function <code>F</code> this method maps every cell <code>x, y</code> as:
+     * <code>A(x,y) = fun(A(x,y), B(x,y))</code>
+     *
+     * @param mtx Argument matrix.
+     * @param fun Mapping function.
+     * @return This function.
+     * @throws CardinalityException Thrown if cardinalities mismatch.
+     */
+    public Matrix map(Matrix mtx, IgniteBiFunction<Double, Double, Double> fun);
+
+    /**
+     * Assigns values from given vector to the specified column in this matrix.
+     *
+     * @param col Column index.
+     * @param vec Vector to get values from.
+     * @return This matrix.
+     * @throws CardinalityException Thrown if cardinalities mismatch.
+     */
+    public Matrix assignColumn(int col, Vector vec);
+
+    /**
+     * Assigns values from given vector to the specified row in this matrix.
+     *
+     * @param row Row index.
+     * @param vec Vector to get values from.
+     * @return This matrix.
+     * @throws CardinalityException Thrown if cardinalities mismatch.
+     */
+    public Matrix assignRow(int row, Vector vec);
+
+    /**
+     * Collects the results of applying a given function to all rows in this matrix.
+     *
+     * @param fun Aggregating function.
+     * @return Vector of row aggregates.
+     */
+    public Vector foldRows(IgniteFunction<Vector, Double> fun);
+
+    /**
+     * Collects the results of applying a given function to all columns in this matrix.
+     *
+     * @param fun Aggregating function.
+     * @return Vector of column aggregates.
+     */
+    public Vector foldColumns(IgniteFunction<Vector, Double> fun);
+
+    /**
+     * Folds this matrix into a single value.
+     *
+     * @param foldFun Folding function that takes two parameters: accumulator and the current value.
+     * @param mapFun Mapping function that is called on each matrix cell before its passed to the accumulator (as its
+     * second parameter).
+     * @param <T> Type of the folded value.
+     * @param zeroVal Zero value for fold function.
+     * @return Folded value of this matrix.
+     */
+    public <T> T foldMap(IgniteBiFunction<T, Double, T> foldFun, IgniteDoubleFunction<Double> mapFun, T zeroVal);
+
+    /**
+     * Calculates the density of the matrix based on supplied criteria.
+     * Returns {@code true} if this matrix is denser than threshold with at least 80% confidence.
+     *
+     * @param threshold the threshold value [0, 1] of non-zero elements above which the matrix is considered dense.
+     */
+    public boolean density(double threshold);
+
+    /**
+     * Gets number of columns in this matrix.
+     *
+     * @return The number of columns in this matrix.
+     */
+    public int columnSize();
+
+    /**
+     * Gets number of rows in this matrix.
+     *
+     * @return The number of rows in this matrix.
+     */
+    public int rowSize();
+
+    /**
+     * Returns matrix determinant using Laplace theorem.
+     *
+     * @return A determinant for this matrix.
+     * @throws CardinalityException Thrown if matrix is not square.
+     */
+    public double determinant();
+
+    /**
+     * Returns the inverse matrix of this matrix
+     *
+     * @return Inverse of this matrix
+     */
+    public Matrix inverse();
+
+    /**
+     * Divides each value in this matrix by the argument.
+     *
+     * @param x Divider value.
+     * @return This matrix.
+     */
+    public Matrix divide(double x);
+
+    /**
+     * Gets the matrix value at the provided location.
+     *
+     * @param row Row index.
+     * @param col Column index.
+     * @return Matrix value.
+     * @throws IndexException Thrown in case of index is out of bound.
+     */
+    public double get(int row, int col);
+
+    /**
+     * Gets the matrix value at the provided location without checking boundaries.
+     * This method is marginally quicker than its {@link #get(int, int)} sibling.
+     *
+     * @param row Row index.
+     * @param col Column index.
+     * @return Matrix value.
+     */
+    public double getX(int row, int col);
+
+    /**
+     * Gets matrix storage model.
+     */
+    public MatrixStorage getStorage();
+
+    /**
+     * Clones this matrix.
+     *
+     * NOTE: new matrix will have the same flavor as the this matrix but a different ID.
+     *
+     * @return New matrix of the same underlying class, the same size and the same values.
+     */
+    public Matrix copy();
+
+    /**
+     * Creates new empty matrix of the same underlying class but of different size.
+     *
+     * NOTE: new matrix will have the same flavor as the this matrix but a different ID.
+     *
+     * @param rows Number of rows for new matrix.
+     * @param cols Number of columns for new matrix.
+     * @return New matrix of the same underlying class and size.
+     */
+    public Matrix like(int rows, int cols);
+
+    /**
+     * Creates new empty vector of compatible properties (similar or the same flavor) to this matrix.
+     *
+     * @param crd Cardinality of the vector.
+     * @return Newly created empty vector "compatible" to this matrix.
+     */
+    public Vector likeVector(int crd);
+
+    /**
+     * Creates new matrix where each value is a difference between corresponding value of this matrix and
+     * passed in argument matrix.
+     *
+     * @param mtx Argument matrix.
+     * @return New matrix of the same underlying class and size.
+     * @throws CardinalityException Thrown if cardinalities mismatch.
+     */
+    public Matrix minus(Matrix mtx);
+
+    /**
+     * Creates new matrix where each value is a sum of the corresponding value of this matrix and
+     * argument value.
+     *
+     * @param x Value to add.
+     * @return New matrix of the same underlying class and size.
+     */
+    public Matrix plus(double x);
+
+    /**
+     * Creates new matrix where each value is a sum of corresponding values of this matrix and
+     * passed in argument matrix.
+     *
+     * @param mtx Argument matrix.
+     * @return New matrix of the same underlying class and size.
+     * @throws CardinalityException Thrown if cardinalities mismatch.
+     */
+    public Matrix plus(Matrix mtx);
+
+    /**
+     * Auto-generated globally unique matrix ID.
+     *
+     * @return Matrix GUID.
+     */
+    public IgniteUuid guid();
+
+    /**
+     * Sets given value.
+     *
+     * @param row Row index.
+     * @param col Column index.
+     * @param val Value to set.
+     * @return This matrix.
+     * @throws IndexException Thrown in case of either index is out of bound.
+     */
+    public Matrix set(int row, int col, double val);
+
+    /**
+     * Sets values for given row.
+     *
+     * @param row Row index.
+     * @param data Row data to set.
+     * @return This matrix.
+     * @throws IndexException Thrown in case of index is out of bound.
+     * @throws CardinalityException Thrown if cardinalities mismatch.
+     */
+    public Matrix setRow(int row, double[] data);
+
+    /**
+     * Sets values for given column.
+     *
+     * @param col Column index.
+     * @param data Column data to set.
+     * @return This matrix.
+     * @throws IndexException Thrown in case of index is out of bound.
+     * @throws CardinalityException Thrown if cardinalities mismatch.
+     */
+    public Matrix setColumn(int col, double[] data);
+
+    /**
+     * Sets given value without checking for index bounds. This method is marginally faster
+     * than its {@link #set(int, int, double)} sibling.
+     *
+     * @param row Row index.
+     * @param col Column index.
+     * @param val Value to set.
+     * @return This matrix.
+     */
+    public Matrix setX(int row, int col, double val);
+
+    /**
+     * Creates new matrix containing the product of given value and values in this matrix.
+     *
+     * @param x Value to multiply.
+     * @return New matrix.
+     */
+    public Matrix times(double x);
+
+    /**
+     * Creates new matrix that is the product of multiplying this matrix and the argument matrix.
+     *
+     * @param mtx Argument matrix.
+     * @return New matrix.
+     * @throws CardinalityException Thrown if cardinalities mismatch.
+     */
+    public Matrix times(Matrix mtx);
+
+    /**
+     * Creates new matrix that is the product of multiplying this matrix and the argument vector.
+     *
+     * @param vec Argument vector.
+     * @return New matrix.
+     * @throws CardinalityException Thrown if cardinalities mismatch.
+     */
+    public Vector times(Vector vec);
+
+    /**
+     * Gets maximum absolute row sum norm of this matrix.
+     * See http://mathworld.wolfram.com/MaximumAbsoluteRowSumNorm.html
+     *
+     * @return Maximum absolute row sum norm of this matrix.
+     */
+    public double maxAbsRowSumNorm();
+
+    /**
+     * Gets sum of all elements in the matrix.
+     *
+     * @return Sum of all elements in this matrix.
+     */
+    public double sum();
+
+    /**
+     * Creates new matrix that is transpose of this matrix.
+     *
+     * @return New transposed matrix.
+     */
+    public Matrix transpose();
+
+    /**
+     * Creates new view into this matrix. Changes to the view will be propagated to this matrix.
+     *
+     * @param off View offset as <code>int[x,y]</code>.
+     * @param size View size as <code>int[rows, cols]</code>
+     * @return New view.
+     * @throws CardinalityException Thrown if cardinalities mismatch.
+     * @throws IndexException Thrown in case of offset is out of bound.
+     */
+    public Matrix viewPart(int[] off, int[] size);
+
+    /**
+     * Creates new view into this matrix. Changes to the view will be propagated to this matrix.
+     *
+     * @param rowOff
+     * @param rows
+     * @param colOff
+     * @param cols
+     * @return New view.
+     * @throws CardinalityException Thrown if cardinalities mismatch.
+     * @throws IndexException Thrown in case of offset is out of bound.
+     */
+    public Matrix viewPart(int rowOff, int rows, int colOff, int cols);
+
+    /**
+     * Creates new view into matrix row. Changes to the view will be propagated to this matrix.
+     *
+     * @param row Row index.
+     * @return New view.
+     * @throws IndexException Thrown in case of index is out of bound.
+     */
+    public Vector viewRow(int row);
+
+    /**
+     * Creates new view into matrix column . Changes to the view will be propagated to this matrix.
+     *
+     * @param col Column index.
+     * @return New view.
+     * @throws IndexException Thrown in case of index is out of bound.
+     */
+    public Vector viewColumn(int col);
+
+    /**
+     * Creates new view into matrix diagonal. Changes to the view will be propagated to this matrix.
+     *
+     * @return New view.
+     */
+    public Vector viewDiagonal();
+
+    /**
+     * Destroys matrix if managed outside of JVM. It's a no-op in all other cases.
+     */
+    public default void destroy() {
+        // No-op.
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/acd21fb8/modules/math/src/main/java/org/apache/ignite/math/MatrixKeyMapper.java
----------------------------------------------------------------------
diff --git a/modules/math/src/main/java/org/apache/ignite/math/MatrixKeyMapper.java b/modules/math/src/main/java/org/apache/ignite/math/MatrixKeyMapper.java
new file mode 100644
index 0000000..d6ae06f
--- /dev/null
+++ b/modules/math/src/main/java/org/apache/ignite/math/MatrixKeyMapper.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.math;
+
+/**
+ * Maps {@link Matrix} row and column index to cache key.
+ */
+public interface MatrixKeyMapper<K> extends KeyMapper<K> {
+    /**
+     * @param x Matrix row index.
+     * @param y Matrix column index.
+     * @return Cache key for given row and column.
+     */
+    public K apply(int x, int y);
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/acd21fb8/modules/math/src/main/java/org/apache/ignite/math/MatrixStorage.java
----------------------------------------------------------------------
diff --git a/modules/math/src/main/java/org/apache/ignite/math/MatrixStorage.java b/modules/math/src/main/java/org/apache/ignite/math/MatrixStorage.java
new file mode 100644
index 0000000..11eced7
--- /dev/null
+++ b/modules/math/src/main/java/org/apache/ignite/math/MatrixStorage.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.math;
+
+import java.io.Externalizable;
+
+/**
+ * Data storage support for {@link Matrix}.
+ */
+public interface MatrixStorage extends Externalizable, StorageOpsMetrics, Destroyable {
+    /**
+     * @param x Matrix row index.
+     * @param y Matrix column index.
+     * @return Value corresponding to given row and column.
+     */
+    public double get(int x, int y);
+
+    /**
+     * @param x Matrix row index.
+     * @param y Matrix column index.
+     * @param v Value to set at given row and column.
+     */
+    public void set(int x, int y, double v);
+
+    /**
+     *
+     */
+    public int columnSize();
+
+    /**
+     *
+     */
+    public int rowSize();
+
+    /**
+     * Gets underlying array if {@link StorageOpsMetrics#isArrayBased()} returns {@code true}.
+     *
+     * @see StorageOpsMetrics#isArrayBased()
+     */
+    default public double[][] data() {
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/acd21fb8/modules/math/src/main/java/org/apache/ignite/math/MetaAttributes.java
----------------------------------------------------------------------
diff --git a/modules/math/src/main/java/org/apache/ignite/math/MetaAttributes.java b/modules/math/src/main/java/org/apache/ignite/math/MetaAttributes.java
new file mode 100644
index 0000000..8973b55
--- /dev/null
+++ b/modules/math/src/main/java/org/apache/ignite/math/MetaAttributes.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.math;
+
+import java.util.Map;
+
+/**
+ * Interface provides support for meta attributes on vectors and matrices.
+ */
+public interface MetaAttributes {
+    /**
+     * Implementation should return an instance of the map to store meta attributes.
+     */
+    public Map<String, Object> getMetaStorage();
+
+    /**
+     * Gets meta attribute with given name.
+     *
+     * @param name Name of the vector meta attribute to get.
+     * @param <T> Attribute's type.
+     */
+    @SuppressWarnings("unchecked")
+    public default <T> T getAttribute(String name) {
+        return (T)getMetaStorage().get(name);
+    }
+
+    /**
+     * Sets meta attribute with given name and value.
+     *
+     * @param name Name of the meta attribute.
+     * @param val Attribute value.
+     * @param <T> Attribute's type.
+     */
+    public default <T> void setAttribute(String name, T val) {
+        getMetaStorage().put(name, val);
+    }
+
+    /**
+     * Removes meta attribute with given name.
+     *
+     * @param name Name of the meta attribute.
+     * @return {@code true} if attribute was present and was removed, {@code false} otherwise.
+     */
+    public default boolean removeAttribute(String name) {
+        boolean is = getMetaStorage().containsKey(name);
+
+        if (is)
+            getMetaStorage().remove(name);
+
+        return is;
+    }
+
+    /**
+     * Checks if given meta attribute is present.
+     *
+     * @param name Attribute name to check.
+     */
+    public default boolean hasAttribute(String name) {
+        return getMetaStorage().containsKey(name);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/acd21fb8/modules/math/src/main/java/org/apache/ignite/math/MurmurHash.java
----------------------------------------------------------------------
diff --git a/modules/math/src/main/java/org/apache/ignite/math/MurmurHash.java b/modules/math/src/main/java/org/apache/ignite/math/MurmurHash.java
new file mode 100644
index 0000000..3d1252e
--- /dev/null
+++ b/modules/math/src/main/java/org/apache/ignite/math/MurmurHash.java
@@ -0,0 +1,246 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.math;
+
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+
+/**
+ * This is a very fast, non-cryptographic hash suitable for general hash-based lookup.
+ *
+ * See http://murmurhash.googlepages.com/ for mre details.
+ */
+public class MurmurHash {
+    /** Hide it. */
+    private MurmurHash() {
+    }
+
+    /**
+     * This produces exactly the same hash values as the final C+ version of MurmurHash3 and is
+     * thus suitable for producing the same hash values across platforms.
+     *
+     * The 32 bit x86 version of this hash should be the fastest variant for relatively short keys like IDs.
+     *
+     * Note - The x86 and x64 versions do _not_ produce the same results, as the algorithms are
+     * optimized for their respective platforms.
+     *
+     * See also http://github.com/yonik/java_util for future updates to this method.
+     *
+     * @param data
+     * @param off
+     * @param len
+     * @param seed
+     * @return 32 bit hash platform compatible with C++ MurmurHash3 implementation on x86.
+     */
+    public static int hash3X86(byte[] data, int off, int len, int seed) {
+        int c1 = 0xcc9e2d51;
+        int c2 = 0x1b873593;
+
+        int h1 = seed;
+        int roundedEnd = off + (len & 0xfffffffc);  // Round down to 4 byte block.
+
+        for (int i = off; i < roundedEnd; i += 4) {
+            int k1 = (data[i] & 0xff) | ((data[i + 1] & 0xff) << 8) | ((data[i + 2] & 0xff) << 16) | (data[i + 3] << 24);
+
+            k1 *= c1;
+            k1 = (k1 << 15) | (k1 >>> 17);
+            k1 *= c2;
+
+            h1 ^= k1;
+            h1 = (h1 << 13) | (h1 >>> 19);
+            h1 = h1 * 5 + 0xe6546b64;
+        }
+
+        // Tail.
+        int k1 = 0;
+
+        switch (len & 0x03) {
+            case 3:
+                k1 = (data[roundedEnd + 2] & 0xff) << 16;
+                // Fallthrough - WTF?
+            case 2:
+                k1 |= (data[roundedEnd + 1] & 0xff) << 8;
+                // Fallthrough - WTF?
+            case 1:
+                k1 |= data[roundedEnd] & 0xff;
+                k1 *= c1;
+                k1 = (k1 << 15) | (k1 >>> 17);
+                k1 *= c2;
+                h1 ^= k1;
+            default:
+        }
+
+        // Finalization.
+        h1 ^= len;
+
+        h1 ^= h1 >>> 16;
+        h1 *= 0x85ebca6b;
+        h1 ^= h1 >>> 13;
+        h1 *= 0xc2b2ae35;
+        h1 ^= h1 >>> 16;
+
+        return h1;
+    }
+
+    /**
+     * Hashes an int.
+     *
+     * @param data The int to hash.
+     * @param seed The seed for the hash.
+     * @return The 32 bit hash of the bytes in question.
+     */
+    public static int hash(int data, int seed) {
+        byte[] arr = new byte[] {
+            (byte)(data >>> 24),
+            (byte)(data >>> 16),
+            (byte)(data >>> 8),
+            (byte)data
+        };
+
+        return hash(ByteBuffer.wrap(arr), seed);
+    }
+
+    /**
+     * Hashes bytes in an array.
+     *
+     * @param data The bytes to hash.
+     * @param seed The seed for the hash.
+     * @return The 32 bit hash of the bytes in question.
+     */
+    public static int hash(byte[] data, int seed) {
+        return hash(ByteBuffer.wrap(data), seed);
+    }
+
+    /**
+     * Hashes bytes in part of an array.
+     *
+     * @param data The data to hash.
+     * @param off Where to start munging.
+     * @param len How many bytes to process.
+     * @param seed The seed to start with.
+     * @return The 32-bit hash of the data in question.
+     */
+    public static int hash(byte[] data, int off, int len, int seed) {
+        return hash(ByteBuffer.wrap(data, off, len), seed);
+    }
+
+    /**
+     * Hashes the bytes in a buffer from the current position to the limit.
+     *
+     * @param buf The bytes to hash.
+     * @param seed The seed for the hash.
+     * @return The 32 bit murmur hash of the bytes in the buffer.
+     */
+    public static int hash(ByteBuffer buf, int seed) {
+        ByteOrder byteOrder = buf.order();
+        buf.order(ByteOrder.LITTLE_ENDIAN);
+
+        int m = 0x5bd1e995;
+        int r = 24;
+
+        int h = seed ^ buf.remaining();
+
+        while (buf.remaining() >= 4) {
+            int k = buf.getInt();
+
+            k *= m;
+            k ^= k >>> r;
+            k *= m;
+
+            h *= m;
+            h ^= k;
+        }
+
+        if (buf.remaining() > 0) {
+            ByteBuffer finish = ByteBuffer.allocate(4).order(ByteOrder.LITTLE_ENDIAN);
+
+            finish.put(buf).rewind();
+
+            h ^= finish.getInt();
+            h *= m;
+        }
+
+        h ^= h >>> 13;
+        h *= m;
+        h ^= h >>> 15;
+
+        buf.order(byteOrder);
+
+        return h;
+    }
+
+    /**
+     * @param data
+     * @param seed
+     */
+    public static long hash64A(byte[] data, int seed) {
+        return hash64A(ByteBuffer.wrap(data), seed);
+    }
+
+    /**
+     * @param data
+     * @param off
+     * @param len
+     * @param seed
+     */
+    public static long hash64A(byte[] data, int off, int len, int seed) {
+        return hash64A(ByteBuffer.wrap(data, off, len), seed);
+    }
+
+    /**
+     * @param buf
+     * @param seed
+     */
+    public static long hash64A(ByteBuffer buf, int seed) {
+        ByteOrder byteOrder = buf.order();
+        buf.order(ByteOrder.LITTLE_ENDIAN);
+
+        long m = 0xc6a4a7935bd1e995L;
+        int r = 47;
+
+        long h = seed ^ (buf.remaining() * m);
+
+        while (buf.remaining() >= 8) {
+            long k = buf.getLong();
+
+            k *= m;
+            k ^= k >>> r;
+            k *= m;
+
+            h ^= k;
+            h *= m;
+        }
+
+        if (buf.remaining() > 0) {
+            ByteBuffer finish = ByteBuffer.allocate(8).order(ByteOrder.LITTLE_ENDIAN);
+
+            finish.put(buf).rewind();
+
+            h ^= finish.getLong();
+            h *= m;
+        }
+
+        h ^= h >>> r;
+        h *= m;
+        h ^= h >>> r;
+
+        buf.order(byteOrder);
+
+        return h;
+    }
+}