apache$hama
v1.add(v2);
    int i = 0;
    Iterator<Writable> it = v1.iterator();
    while (it.hasNext()) {
      DoubleEntry c = (DoubleEntry) it.next();
      assertEquals(c.getValue(), values[0][i] + values[1][i]);
      i++;
void
void add()
v1.add(v2);
    int i = 0;
    Iterator<Writable> it = v1.iterator();
    while (it.hasNext()) {
      DoubleEntry c = (DoubleEntry) it.next();
      assertEquals(c.getValue(), values[0][i] + values[1][i]);
      i++;
void
void testAdd()
apache$hama
void
void addTest()
void
void testAdd()
apache$hama
Matrix m1,Matrix m2
void
void addAlphaMatrix(Matrix m1,Matrix m2)
void
void testAddAlphaMatrix()
apache$hama
((DenseVector) v1).clear();
    assertEquals(v1.size(), 0);
void
void clear()
((DenseVector) v1).clear();
    assertEquals(v1.size(), 0);
void
void testClear()
apache$hama
void
void testDenseVector()
void
void testDot()
apache$hama
void
void getSetTest()
void
void testGetSet()
apache$hama
Matrix m1,Matrix m2
void
void matrixAdd(Matrix m1,Matrix m2)
void
void testMatrixAdd()
apache$hama
Matrix m1,Matrix m2
void
void matrixMult(Matrix m1,Matrix m2)
void
void testMatrixMult()
apache$hama
void
void testMult()
void
void testMatrixMult()
apache$hama
Matrix m1,Matrix m2,Matrix m3
void
void multMatrixAdd(Matrix m1,Matrix m2,Matrix m3)
void
void testMultiMatrixAdd()
apache$hama
v1.set(v2);

    for(int i = 0; i < v1.size(); i ++) {
      assertEquals(v2.get(i), v1.get(i));
void
void setTest()
v1.set(v2);
    
    for(int i = 0; i < v1.size(); i ++) {
      assertEquals(v2.get(i), v1.get(i));
void
void testSet()
apache$hama
Matrix m1
void
void setAlphaMatrix(Matrix m1)
void
void testSetAlphaMatrix()
apache$hama
Matrix m1
void
void setMatrix(Matrix m1)
void
void testSetMatrix()
apache$hama
void
void setRowColumn()
void
void testSetRow()
apache$hama
void
void sparsity()
void
void testSparsity()
apache$hama
int start = 2;
    Vector subVector = v1.subVector(start, v1.size() - 1);
    Iterator<Writable> it = subVector.iterator();

    int i = start;
    while (it.hasNext()) {
      assertEquals(v1.get(i), ((DoubleEntry) it.next()).getValue());
      i++;
void
void subVector()
int start = 2;
    Vector subVector = v1.subVector(start, v1.size() - 1);
    Iterator<Writable> it = subVector.iterator();

    int i = start;
    while (it.hasNext()) {
      assertEquals(v1.get(i), ((DoubleEntry) it.next()).getValue());
      i++;
void
void testSubVector()
https://github.com/apache/hama/blob/42584cd5328fc55a499d318dda6fefff6459242c/CHANGES.txt
https://api.github.com/repos/apache/hama/contents/CHANGES.txt?ref=42584cd5328fc55a499d318dda6fefff6459242c
CHANGES.txt
    HAMA-188: Upgrade dependencies for hadoop/hbase 2.0 (edwardyoon)
@@ -40,6 +40,7 @@ Trunk (unreleased changes)
 
   IMPROVEMENTS
 
+    HAMA-188: Upgrade dependencies for hadoop/hbase 2.0 (edwardyoon)
     HAMA-192: Refactor top-level package (edwardyoon)
     HAMA-189: Update website (edwardyoon)
     HAMA-187: Add matrix subtraction test case (edwardyoon)
https://github.com/apache/hama/raw/42584cd5328fc55a499d318dda6fefff6459242c/CHANGES.txt
a0ae72a6a567226cb201224eda80907fb4e8931d
modified
https://github.com/apache/hama/blob/42584cd5328fc55a499d318dda6fefff6459242c/build.xml
https://api.github.com/repos/apache/hama/contents/build.xml?ref=42584cd5328fc55a499d318dda6fefff6459242c
build.xml
<?xml version="1.0"?>

<!--
   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.
-->

<project name="hama" default="jar">
    <property name="version" value="0.2.0-dev" />
    <property name="Name" value="Hama" />
    <property name="final.name" value="hama-${version}" />
    <property name="year" value="2009" />

    <!-- Load all the default properties, and any the user wants    -->
    <!-- to contribute (without having to type -D or edit this file -->
    <property file="${user.home}/${name}.build.properties" />
    <property file="${basedir}/build.properties" />

    <property name="src.dir" location="${basedir}/src/java" />
    <property name="src.gen.dir" location="${basedir}/src-gen" />
    <property name="src.test" location="${basedir}/src/test" />
    <property name="src.examples" location="${basedir}/src/examples" />

    <property name="lib.dir" value="${basedir}/lib" />
    <property name="conf.dir" value="${basedir}/conf" />
    <property name="docs.dir" value="${basedir}/docs" />
    <property name="docs.src" value="${basedir}/src/docs" />

	<!-- javacc properties -->
    <property name="javacc.home" value="${basedir}/lib" />

    <property name="src.gen.parser.expression.dir" value="${src.gen.dir}/org/apache/hama/shell/parser/expression" />
    <property name="src.gen.parser.script.dir" value="${src.gen.dir}/org/apache/hama/shell/parser/script" />

	<!-- build properties -->
	
    <property name="test.output" value="no" />
    <property name="test.timeout" value="600000" />

    <property name="build.dir" location="${basedir}/build" />
    <property name="build.lib" location="${build.dir}/lib" />
    <property name="build.classes" location="${build.dir}/classes" />
    <property name="build.test" location="${build.dir}/test" />
    <property name="build.examples" location="${build.dir}/examples" />
    <property name="build.docs" value="${build.dir}/docs/site" />
    <property name="build.javadoc" value="${build.docs}/api" />
    <property name="build.encoding" value="ISO-8859-1" />
    <property name="build.src" value="${build.dir}/src" />
    
    <property name="build.report" value="${build.dir}/reports" />
    <property name="build.report.findbugs" value="${build.report}/findbugs" />
    <property name="build.report.tests" value="${build.report}/tests" />
    
    <property name="test.build.dir" value="${build.dir}/test" />
    <property name="test.junit.output.format" value="plain" />

    <property name="dist.dir" value="${build.dir}/${final.name}" />

    <property name="javac.deprecation" value="off" />
    <property name="javac.debug" value="on" />

    <property name="javadoc.link.java" 
                 value="http://java.sun.com/javase/6/docs/api/" />
    <property name="javadoc.packages" value="org.apache.hama.*" />

    <fileset id="lib.jars" dir="${basedir}" includes="lib/*.jar" />
    <path id="classpath">
        <fileset refid="lib.jars" />
        <fileset dir="${lib.dir}/findbugs/">
            <include name="*jar" />
        </fileset>
        <pathelement location="${build.classes}" />
        <pathelement location="${conf.dir}" />
    </path>

    <taskdef name="findbugs" classpathref="classpath" 
    	classname="edu.umd.cs.findbugs.anttask.FindBugsTask" />

    <target name="init">
        <mkdir dir="${src.gen.dir}" />
        <mkdir dir="${src.gen.parser.script.dir}" />
        <mkdir dir="${src.gen.parser.expression.dir}" />
        <mkdir dir="${build.dir}" />
        <mkdir dir="${build.classes}" />
        <mkdir dir="${build.test}" />
        <mkdir dir="${build.examples}" />
        <mkdir dir="${build.report.findbugs}" />
        <mkdir dir="${build.report.tests}" />
        <!--Copy bin, lib, and conf. too-->
        <mkdir dir="${build.lib}" />
        <copy todir="${build.lib}">
            <fileset dir="${lib.dir}" />
        </copy>
    </target>
	
	<!-- ================================================================== -->
    <!-- Java Compiler Compiler, generate Parsers                           -->
    <!-- ================================================================== -->
    <target name="cc-compile" depends="init" description="Create and Compile Parser">
        <jjtree target="${src.dir}/org/apache/hama/shell/parser/expression/HamaExpressionParser.jjt" outputdirectory="${src.gen.parser.expression.dir}" javacchome="${javacc.home}" />
        <javacc target="${src.gen.parser.expression.dir}/HamaExpressionParser.jj" outputdirectory="${src.gen.parser.expression.dir}" javacchome="${javacc.home}" />
        <javacc target="${src.dir}/org/apache/hama/shell/parser/script/HamaScriptParser.jj" outputdirectory="${src.gen.parser.script.dir}" javacchome="${javacc.home}" />
    </target>

    <target name="compile" depends="init, cc-compile">
        <!--Compile whats under src and generated java classes made from jsp-->
        <mkdir dir="${build.src}" />
        <javac encoding="${build.encoding}" 
                srcdir="${src.dir};${src.gen.dir};${build.src}" includes="**/*.java" 
        	destdir="${build.classes}" debug="${javac.debug}" 
                deprecation="${javac.deprecation}">
            <classpath refid="classpath" />
        </javac>
    </target>

    <target name="compile-examples" depends="compile">
        <javac encoding="${build.encoding}" srcdir="${src.examples}" 
                includes="**/*.java" 
        	destdir="${build.examples}" debug="${javac.debug}" 
                deprecation="${javac.deprecation}">
            <classpath refid="classpath" />
        </javac>
    </target>

    <!-- Override jar target to specify main class -->
    <target name="jar" depends="compile">
        <jar jarfile="${build.dir}/${final.name}.jar" 
              basedir="${build.classes}">
            <manifest>
                <attribute name="Main-Class" 
                    value="org/apache/hama/shell/HamaShell" />
            </manifest>
        </jar>
    </target>

    <target name="examples" depends="jar, compile-examples" 
    	description="Make the hama examples jar.">
        <jar jarfile="${build.dir}/${final.name}-examples.jar" 
                basedir="${build.examples}">
            <manifest>
                <attribute name="Main-Class" 
                    value="org/apache/hama/examples/ExampleDriver" />
            </manifest>
        </jar>
    </target>

    <target name="package" depends="jar,javadoc,compile-test, examples" 
    	description="Build distribution">
        <mkdir dir="${dist.dir}" />
        <copy todir="${dist.dir}" includeEmptyDirs="false" flatten="true">
            <fileset dir="${build.dir}">
                <include name="${final.name}.jar" />
                <include name="${final.name}-test.jar" />
            </fileset>
        </copy>
        <mkdir dir="${dist.dir}/lib" />
        <copy todir="${dist.dir}/lib">
            <fileset dir="${build.lib}" />
        </copy>
        <copy todir="${dist.dir}">
            <fileset dir=".">
                <include name="*.txt" />
            </fileset>
        </copy>
        <mkdir dir="${dist.dir}/src" />
        <copy todir="${dist.dir}/src" includeEmptyDirs="true">
            <fileset dir="src" excludes="**/*.template **/docs/build/**/*" />
        </copy>
    </target>

    <!-- ================================================================== -->
    <!-- Make release tarball                                               -->
    <!-- ================================================================== -->
    <macrodef name="macro_tar" description="Worker Macro for tar">
        <attribute name="param.destfile" />
        <element name="param.listofitems" />
        <sequential>
            <tar compression="gzip" longfile="gnu" destfile="@{param.destfile}">
                <param.listofitems />
            </tar>
        </sequential>
    </macrodef>
    <target name="tar" depends="package" description="Make release tarball">
        <macro_tar param.destfile="${build.dir}/${final.name}.tar.gz">
            <param.listofitems>
                <tarfileset dir="${build.dir}" mode="664">
                    <exclude name="${final.name}/bin/*" />
                    <include name="${final.name}/**" />
                </tarfileset>
                <tarfileset dir="${build.dir}" mode="755">
                    <include name="${final.name}/bin/*" />
                </tarfileset>
            </param.listofitems>
        </macro_tar>
    </target>

    <target name="binary" depends="package" 
    	description="Make tarball without source and documentation">
        <macro_tar param.destfile="${build.dir}/${final.name}-bin.tar.gz">
            <param.listofitems>
                <tarfileset dir="${build.dir}" mode="664">
                    <exclude name="${final.name}/bin/*" />
                    <exclude name="${final.name}/src/**" />
                    <exclude name="${final.name}/docs/**" />
                    <include name="${final.name}/**" />
                </tarfileset>
                <tarfileset dir="${build.dir}" mode="755">
                    <include name="${final.name}/bin/*" />
                </tarfileset>
            </param.listofitems>
        </macro_tar>
    </target>

    <!-- ================================================================== -->
    <!-- Doc                                                                -->
    <!-- ================================================================== -->
    <target name="docs" depends="forrest.check" description="Generate forrest-based documentation. To use, specify -Dforrest.home=&lt;base of Apache Forrest installation&gt; on the command line." if="forrest.home">
        <exec dir="${docs.src}" executable="${forrest.home}/bin/forrest" 
               failonerror="true">
        	<env key="JAVA_HOME" value="${java5.home}"/>
        </exec>
        <copy todir="${build.docs}">
          <fileset dir="${docs.src}/build/site/" />
        </copy>
    	<delete dir="${docs.src}/build/"/>
    </target>

    <target name="forrest.check" unless="forrest.home">
        <fail message="'forrest.home' is not defined. Please pass -Dforrest.home=&lt;base of Apache Forrest installation&gt; to Ant on the command-line." />
    </target>

    <!-- Javadoc -->
    <target name="javadoc" depends="cc-compile" description="Generate javadoc">
        <mkdir dir="${build.javadoc}" />
        <javadoc overview="${src.dir}/overview.html" packagenames="org.apache.hama.*" 
        	    destdir="${build.javadoc}" author="true" version="true" use="true" 
        	    windowtitle="${Name} ${version} API" doctitle="${Name} ${version} API" 
        	    bottom="Copyright &amp;copy; ${year} The Apache Software Foundation">
            <packageset dir="${src.dir}">
                <include name="org/apache/**" />
            </packageset>
            <packageset dir="${src.gen.dir}">
                <include name="org/apache/**" />
            </packageset>
            <link href="${javadoc.link.java}" />
            <classpath>
                <path refid="classpath" />
                <pathelement path="${java.class.path}" />
            </classpath>
            <group title="${Name}" packages="org.apache.hama.*" />
        </javadoc>
    </target>

    <!-- ================================================================== -->
    <!-- Run unit tests                                                     -->
    <!-- ================================================================== -->
    <path id="test.classpath">
        <pathelement location="${src.test}" />
        <pathelement location="${build.test}" />
        <path refid="classpath" />
        <pathelement location="${build.dir}" />
    </path>

    <target name="compile-test" depends="compile">
        <javac encoding="${build.encoding}" srcdir="${src.test}" 
           includes="**/*.java" destdir="${build.test}" debug="${javac.debug}">
            <classpath refid="test.classpath" />
        </javac>
        <jar jarfile="${build.dir}/${final.name}-test.jar">
            <fileset dir="${build.test}" includes="org/**" />
            <fileset dir="${build.classes}" />
            <fileset dir="${src.test}" includes="**/*.properties" />
            <manifest>
              <attribute name="Main-Class" value="org/apache/hama/Benchmarks" />
            </manifest>
        </jar>
    </target>

    <target name="test" depends="compile-test, compile">
        <junit printsummary="yes" showoutput="${test.output}" haltonfailure="no"
              fork="yes" maxmemory="512m" errorProperty="tests.failed" 
        	     failureProperty="tests.failed" timeout="${test.timeout}">
            <classpath refid="test.classpath" />
            <formatter type="${test.junit.output.format}" />
            <batchtest todir="${build.report.tests}">
                <fileset dir="${src.test}" includes="**/Test*.java" 
                	 excludes="**/${test.exclude}.java" />
            </batchtest>
        </junit>
        <fail if="tests.failed">Tests failed!</fail>
    </target>

    <target name="findbugs" depends="init, jar">
        <findbugs home="${lib.dir}/findbugs" output="xml" 
        	     outputFile="${build.report.findbugs}/hama-findbugs.xml" 
               excludeFilter="${conf.dir}/findbugs-exclude-filter.xml"
        	     auxClasspathRef="classpath">
            <sourcePath path="${src.dir}" />
            <class location="${build.dir}/${final.name}.jar" />
        </findbugs>
    </target>
    
    <target name="report" depends="findbugs,test"></target>
    
    <!-- ================================================================== -->
    <!-- Clean.  Delete the build files, and their directories              -->
    <!-- ================================================================== -->
    <target name="clean">
        <delete dir="${src.gen.dir}" />
        <delete dir="${build.dir}" />
    </target>
</project>
<?xml version="1.0"?>

<!--
   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.
-->

<project name="hama" default="jar">
    <property name="version" value="0.1.0-dev" />
    <property name="Name" value="Hama" />
    <property name="final.name" value="hama-${version}" />
    <property name="year" value="2008" />

    <!-- Load all the default properties, and any the user wants    -->
    <!-- to contribute (without having to type -D or edit this file -->
    <property file="${user.home}/${name}.build.properties" />
    <property file="${basedir}/build.properties" />

    <property name="src.dir" location="${basedir}/src/java" />
    <property name="src.gen.dir" location="${basedir}/src-gen" />
    <property name="src.test" location="${basedir}/src/test" />
    <property name="src.examples" location="${basedir}/src/examples" />

    <property name="lib.dir" value="${basedir}/lib" />
    <property name="conf.dir" value="${basedir}/conf" />
    <property name="docs.dir" value="${basedir}/docs" />
    <property name="docs.src" value="${basedir}/src/docs" />

	<!-- javacc properties -->
    <property name="javacc.home" value="${basedir}/lib" />

    <property name="src.gen.parser.expression.dir" value="${src.gen.dir}/org/apache/hama/shell/parser/expression" />
    <property name="src.gen.parser.script.dir" value="${src.gen.dir}/org/apache/hama/shell/parser/script" />

	<!-- build properties -->
	
    <property name="test.output" value="no" />
    <property name="test.timeout" value="600000" />

    <property name="build.dir" location="${basedir}/build" />
    <property name="build.lib" location="${build.dir}/lib" />
    <property name="build.classes" location="${build.dir}/classes" />
    <property name="build.test" location="${build.dir}/test" />
    <property name="build.examples" location="${build.dir}/examples" />
    <property name="build.docs" value="${build.dir}/docs/site" />
    <property name="build.javadoc" value="${build.docs}/api" />
    <property name="build.encoding" value="ISO-8859-1" />
    <property name="build.src" value="${build.dir}/src" />
    
    <property name="build.report" value="${build.dir}/reports" />
    <property name="build.report.findbugs" value="${build.report}/findbugs" />
    <property name="build.report.tests" value="${build.report}/tests" />
    
    <property name="test.build.dir" value="${build.dir}/test" />
    <property name="test.junit.output.format" value="plain" />

    <property name="dist.dir" value="${build.dir}/${final.name}" />

    <property name="javac.deprecation" value="off" />
    <property name="javac.debug" value="on" />

    <property name="javadoc.link.java" 
                 value="http://java.sun.com/javase/6/docs/api/" />
    <property name="javadoc.packages" value="org.apache.hama.*" />

    <fileset id="lib.jars" dir="${basedir}" includes="lib/*.jar" />
    <path id="classpath">
        <fileset refid="lib.jars" />
        <fileset dir="${lib.dir}/jetty-ext/">
            <include name="*jar" />
        </fileset>
        <fileset dir="${lib.dir}/findbugs/">
            <include name="*jar" />
        </fileset>
        <pathelement location="${build.classes}" />
        <pathelement location="${conf.dir}" />
    </path>

    <taskdef name="findbugs" classpathref="classpath" 
    	classname="edu.umd.cs.findbugs.anttask.FindBugsTask" />

    <target name="init">
        <mkdir dir="${src.gen.dir}" />
        <mkdir dir="${src.gen.parser.script.dir}" />
        <mkdir dir="${src.gen.parser.expression.dir}" />
        <mkdir dir="${build.dir}" />
        <mkdir dir="${build.classes}" />
        <mkdir dir="${build.test}" />
        <mkdir dir="${build.examples}" />
        <mkdir dir="${build.report.findbugs}" />
        <mkdir dir="${build.report.tests}" />
        <!--Copy bin, lib, and conf. too-->
        <mkdir dir="${build.lib}" />
        <copy todir="${build.lib}">
            <fileset dir="${lib.dir}" />
        </copy>
    </target>
	
	<!-- ================================================================== -->
    <!-- Java Compiler Compiler, generate Parsers                           -->
    <!-- ================================================================== -->
    <target name="cc-compile" depends="init" description="Create and Compile Parser">
        <jjtree target="${src.dir}/org/apache/hama/shell/parser/expression/HamaExpressionParser.jjt" outputdirectory="${src.gen.parser.expression.dir}" javacchome="${javacc.home}" />
        <javacc target="${src.gen.parser.expression.dir}/HamaExpressionParser.jj" outputdirectory="${src.gen.parser.expression.dir}" javacchome="${javacc.home}" />
        <javacc target="${src.dir}/org/apache/hama/shell/parser/script/HamaScriptParser.jj" outputdirectory="${src.gen.parser.script.dir}" javacchome="${javacc.home}" />
    </target>

    <target name="compile" depends="init, cc-compile">
        <!--Compile whats under src and generated java classes made from jsp-->
        <mkdir dir="${build.src}" />
        <javac encoding="${build.encoding}" 
                srcdir="${src.dir};${src.gen.dir};${build.src}" includes="**/*.java" 
        	destdir="${build.classes}" debug="${javac.debug}" 
                deprecation="${javac.deprecation}">
            <classpath refid="classpath" />
        </javac>
    </target>

    <target name="compile-examples" depends="compile">
        <javac encoding="${build.encoding}" srcdir="${src.examples}" 
                includes="**/*.java" 
        	destdir="${build.examples}" debug="${javac.debug}" 
                deprecation="${javac.deprecation}">
            <classpath refid="classpath" />
        </javac>
    </target>

    <!-- Override jar target to specify main class -->
    <target name="jar" depends="compile">
        <jar jarfile="${build.dir}/${final.name}.jar" 
              basedir="${build.classes}">
            <manifest>
                <attribute name="Main-Class" 
                    value="org/apache/hama/shell/HamaShell" />
            </manifest>
        </jar>
    </target>

    <target name="examples" depends="jar, compile-examples" 
    	description="Make the hama examples jar.">
        <jar jarfile="${build.dir}/${final.name}-examples.jar" 
                basedir="${build.examples}">
            <manifest>
                <attribute name="Main-Class" 
                    value="org/apache/hama/examples/ExampleDriver" />
            </manifest>
        </jar>
    </target>

    <target name="package" depends="jar,javadoc,compile-test, examples" 
    	description="Build distribution">
        <mkdir dir="${dist.dir}" />
        <copy todir="${dist.dir}" includeEmptyDirs="false" flatten="true">
            <fileset dir="${build.dir}">
                <include name="${final.name}.jar" />
                <include name="${final.name}-test.jar" />
            </fileset>
        </copy>
        <mkdir dir="${dist.dir}/lib" />
        <copy todir="${dist.dir}/lib">
            <fileset dir="${build.lib}" />
        </copy>
        <copy todir="${dist.dir}">
            <fileset dir=".">
                <include name="*.txt" />
            </fileset>
        </copy>
        <mkdir dir="${dist.dir}/src" />
        <copy todir="${dist.dir}/src" includeEmptyDirs="true">
            <fileset dir="src" excludes="**/*.template **/docs/build/**/*" />
        </copy>
    </target>

    <!-- ================================================================== -->
    <!-- Make release tarball                                               -->
    <!-- ================================================================== -->
    <macrodef name="macro_tar" description="Worker Macro for tar">
        <attribute name="param.destfile" />
        <element name="param.listofitems" />
        <sequential>
            <tar compression="gzip" longfile="gnu" destfile="@{param.destfile}">
                <param.listofitems />
            </tar>
        </sequential>
    </macrodef>
    <target name="tar" depends="package" description="Make release tarball">
        <macro_tar param.destfile="${build.dir}/${final.name}.tar.gz">
            <param.listofitems>
                <tarfileset dir="${build.dir}" mode="664">
                    <exclude name="${final.name}/bin/*" />
                    <include name="${final.name}/**" />
                </tarfileset>
                <tarfileset dir="${build.dir}" mode="755">
                    <include name="${final.name}/bin/*" />
                </tarfileset>
            </param.listofitems>
        </macro_tar>
    </target>

    <target name="binary" depends="package" 
    	description="Make tarball without source and documentation">
        <macro_tar param.destfile="${build.dir}/${final.name}-bin.tar.gz">
            <param.listofitems>
                <tarfileset dir="${build.dir}" mode="664">
                    <exclude name="${final.name}/bin/*" />
                    <exclude name="${final.name}/src/**" />
                    <exclude name="${final.name}/docs/**" />
                    <include name="${final.name}/**" />
                </tarfileset>
                <tarfileset dir="${build.dir}" mode="755">
                    <include name="${final.name}/bin/*" />
                </tarfileset>
            </param.listofitems>
        </macro_tar>
    </target>

    <!-- ================================================================== -->
    <!-- Doc                                                                -->
    <!-- ================================================================== -->
    <target name="docs" depends="forrest.check" description="Generate forrest-based documentation. To use, specify -Dforrest.home=&lt;base of Apache Forrest installation&gt; on the command line." if="forrest.home">
        <exec dir="${docs.src}" executable="${forrest.home}/bin/forrest" 
               failonerror="true">
        	<env key="JAVA_HOME" value="${java5.home}"/>
        </exec>
        <copy todir="${build.docs}">
          <fileset dir="${docs.src}/build/site/" />
        </copy>
    	<delete dir="${docs.src}/build/"/>
    </target>

    <target name="forrest.check" unless="forrest.home">
        <fail message="'forrest.home' is not defined. Please pass -Dforrest.home=&lt;base of Apache Forrest installation&gt; to Ant on the command-line." />
    </target>

    <!-- Javadoc -->
    <target name="javadoc" depends="cc-compile" description="Generate javadoc">
        <mkdir dir="${build.javadoc}" />
        <javadoc overview="${src.dir}/overview.html" packagenames="org.apache.hama.*" 
        	    destdir="${build.javadoc}" author="true" version="true" use="true" 
        	    windowtitle="${Name} ${version} API" doctitle="${Name} ${version} API" 
        	    bottom="Copyright &amp;copy; ${year} The Apache Software Foundation">
            <packageset dir="${src.dir}">
                <include name="org/apache/**" />
            </packageset>
            <packageset dir="${src.gen.dir}">
                <include name="org/apache/**" />
            </packageset>
            <link href="${javadoc.link.java}" />
            <classpath>
                <path refid="classpath" />
                <pathelement path="${java.class.path}" />
            </classpath>
            <group title="${Name}" packages="org.apache.hama.*" />
        </javadoc>
    </target>

    <!-- ================================================================== -->
    <!-- Run unit tests                                                     -->
    <!-- ================================================================== -->
    <path id="test.classpath">
        <pathelement location="${src.test}" />
        <pathelement location="${build.test}" />
        <path refid="classpath" />
        <pathelement location="${build.dir}" />
    </path>

    <target name="compile-test" depends="compile">
        <javac encoding="${build.encoding}" srcdir="${src.test}" 
           includes="**/*.java" destdir="${build.test}" debug="${javac.debug}">
            <classpath refid="test.classpath" />
        </javac>
        <jar jarfile="${build.dir}/${final.name}-test.jar">
            <fileset dir="${build.test}" includes="org/**" />
            <fileset dir="${build.classes}" />
            <fileset dir="${src.test}" includes="**/*.properties" />
            <manifest>
              <attribute name="Main-Class" value="org/apache/hama/Benchmarks" />
            </manifest>
        </jar>
    </target>

    <target name="test" depends="compile-test, compile">
        <junit printsummary="yes" showoutput="${test.output}" haltonfailure="no"
              fork="yes" maxmemory="512m" errorProperty="tests.failed" 
        	     failureProperty="tests.failed" timeout="${test.timeout}">
            <classpath refid="test.classpath" />
            <formatter type="${test.junit.output.format}" />
            <batchtest todir="${build.report.tests}">
                <fileset dir="${src.test}" includes="**/Test*.java" 
                	 excludes="**/${test.exclude}.java" />
            </batchtest>
        </junit>
        <fail if="tests.failed">Tests failed!</fail>
    </target>

    <target name="findbugs" depends="init, jar">
        <findbugs home="${lib.dir}/findbugs" output="xml" 
        	     outputFile="${build.report.findbugs}/hama-findbugs.xml" 
               excludeFilter="${conf.dir}/findbugs-exclude-filter.xml"
        	     auxClasspathRef="classpath">
            <sourcePath path="${src.dir}" />
            <class location="${build.dir}/${final.name}.jar" />
        </findbugs>
    </target>
    
    <target name="report" depends="findbugs,test"></target>
    
    <!-- ================================================================== -->
    <!-- Clean.  Delete the build files, and their directories              -->
    <!-- ================================================================== -->
    <target name="clean">
        <delete dir="${src.gen.dir}" />
        <delete dir="${build.dir}" />
    </target>
</project>

@@ -1,327 +1,324 @@
-<?xml version="1.0"?>
-
-<!--
-   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.
--->
-
-<project name="hama" default="jar">
-    <property name="version" value="0.1.0-dev" />
-    <property name="Name" value="Hama" />
-    <property name="final.name" value="hama-${version}" />
-    <property name="year" value="2008" />
-
-    <!-- Load all the default properties, and any the user wants    -->
-    <!-- to contribute (without having to type -D or edit this file -->
-    <property file="${user.home}/${name}.build.properties" />
-    <property file="${basedir}/build.properties" />
-
-    <property name="src.dir" location="${basedir}/src/java" />
-    <property name="src.gen.dir" location="${basedir}/src-gen" />
-    <property name="src.test" location="${basedir}/src/test" />
-    <property name="src.examples" location="${basedir}/src/examples" />
-
-    <property name="lib.dir" value="${basedir}/lib" />
-    <property name="conf.dir" value="${basedir}/conf" />
-    <property name="docs.dir" value="${basedir}/docs" />
-    <property name="docs.src" value="${basedir}/src/docs" />
-
-	<!-- javacc properties -->
-    <property name="javacc.home" value="${basedir}/lib" />
-
-    <property name="src.gen.parser.expression.dir" value="${src.gen.dir}/org/apache/hama/shell/parser/expression" />
-    <property name="src.gen.parser.script.dir" value="${src.gen.dir}/org/apache/hama/shell/parser/script" />
-
-	<!-- build properties -->
-	
-    <property name="test.output" value="no" />
-    <property name="test.timeout" value="600000" />
-
-    <property name="build.dir" location="${basedir}/build" />
-    <property name="build.lib" location="${build.dir}/lib" />
-    <property name="build.classes" location="${build.dir}/classes" />
-    <property name="build.test" location="${build.dir}/test" />
-    <property name="build.examples" location="${build.dir}/examples" />
-    <property name="build.docs" value="${build.dir}/docs/site" />
-    <property name="build.javadoc" value="${build.docs}/api" />
-    <property name="build.encoding" value="ISO-8859-1" />
-    <property name="build.src" value="${build.dir}/src" />
-    
-    <property name="build.report" value="${build.dir}/reports" />
-    <property name="build.report.findbugs" value="${build.report}/findbugs" />
-    <property name="build.report.tests" value="${build.report}/tests" />
-    
-    <property name="test.build.dir" value="${build.dir}/test" />
-    <property name="test.junit.output.format" value="plain" />
-
-    <property name="dist.dir" value="${build.dir}/${final.name}" />
-
-    <property name="javac.deprecation" value="off" />
-    <property name="javac.debug" value="on" />
-
-    <property name="javadoc.link.java" 
-                 value="http://java.sun.com/javase/6/docs/api/" />
-    <property name="javadoc.packages" value="org.apache.hama.*" />
-
-    <fileset id="lib.jars" dir="${basedir}" includes="lib/*.jar" />
-    <path id="classpath">
-        <fileset refid="lib.jars" />
-        <fileset dir="${lib.dir}/jetty-ext/">
-            <include name="*jar" />
-        </fileset>
-        <fileset dir="${lib.dir}/findbugs/">
-            <include name="*jar" />
-        </fileset>
-        <pathelement location="${build.classes}" />
-        <pathelement location="${conf.dir}" />
-    </path>
-
-    <taskdef name="findbugs" classpathref="classpath" 
-    	classname="edu.umd.cs.findbugs.anttask.FindBugsTask" />
-
-    <target name="init">
-        <mkdir dir="${src.gen.dir}" />
-        <mkdir dir="${src.gen.parser.script.dir}" />
-        <mkdir dir="${src.gen.parser.expression.dir}" />
-        <mkdir dir="${build.dir}" />
-        <mkdir dir="${build.classes}" />
-        <mkdir dir="${build.test}" />
-        <mkdir dir="${build.examples}" />
-        <mkdir dir="${build.report.findbugs}" />
-        <mkdir dir="${build.report.tests}" />
-        <!--Copy bin, lib, and conf. too-->
-        <mkdir dir="${build.lib}" />
-        <copy todir="${build.lib}">
-            <fileset dir="${lib.dir}" />
-        </copy>
-    </target>
-	
-	<!-- ================================================================== -->
-    <!-- Java Compiler Compiler, generate Parsers                           -->
-    <!-- ================================================================== -->
-    <target name="cc-compile" depends="init" description="Create and Compile Parser">
-        <jjtree target="${src.dir}/org/apache/hama/shell/parser/expression/HamaExpressionParser.jjt" outputdirectory="${src.gen.parser.expression.dir}" javacchome="${javacc.home}" />
-        <javacc target="${src.gen.parser.expression.dir}/HamaExpressionParser.jj" outputdirectory="${src.gen.parser.expression.dir}" javacchome="${javacc.home}" />
-        <javacc target="${src.dir}/org/apache/hama/shell/parser/script/HamaScriptParser.jj" outputdirectory="${src.gen.parser.script.dir}" javacchome="${javacc.home}" />
-    </target>
-
-    <target name="compile" depends="init, cc-compile">
-        <!--Compile whats under src and generated java classes made from jsp-->
-        <mkdir dir="${build.src}" />
-        <javac encoding="${build.encoding}" 
-                srcdir="${src.dir};${src.gen.dir};${build.src}" includes="**/*.java" 
-        	destdir="${build.classes}" debug="${javac.debug}" 
-                deprecation="${javac.deprecation}">
-            <classpath refid="classpath" />
-        </javac>
-    </target>
-
-    <target name="compile-examples" depends="compile">
-        <javac encoding="${build.encoding}" srcdir="${src.examples}" 
-                includes="**/*.java" 
-        	destdir="${build.examples}" debug="${javac.debug}" 
-                deprecation="${javac.deprecation}">
-            <classpath refid="classpath" />
-        </javac>
-    </target>
-
-    <!-- Override jar target to specify main class -->
-    <target name="jar" depends="compile">
-        <jar jarfile="${build.dir}/${final.name}.jar" 
-              basedir="${build.classes}">
-            <manifest>
-                <attribute name="Main-Class" 
-                    value="org/apache/hama/shell/HamaShell" />
-            </manifest>
-        </jar>
-    </target>
-
-    <target name="examples" depends="jar, compile-examples" 
-    	description="Make the hama examples jar.">
-        <jar jarfile="${build.dir}/${final.name}-examples.jar" 
-                basedir="${build.examples}">
-            <manifest>
-                <attribute name="Main-Class" 
-                    value="org/apache/hama/examples/ExampleDriver" />
-            </manifest>
-        </jar>
-    </target>
-
-    <target name="package" depends="jar,javadoc,compile-test, examples" 
-    	description="Build distribution">
-        <mkdir dir="${dist.dir}" />
-        <copy todir="${dist.dir}" includeEmptyDirs="false" flatten="true">
-            <fileset dir="${build.dir}">
-                <include name="${final.name}.jar" />
-                <include name="${final.name}-test.jar" />
-            </fileset>
-        </copy>
-        <mkdir dir="${dist.dir}/lib" />
-        <copy todir="${dist.dir}/lib">
-            <fileset dir="${build.lib}" />
-        </copy>
-        <copy todir="${dist.dir}">
-            <fileset dir=".">
-                <include name="*.txt" />
-            </fileset>
-        </copy>
-        <mkdir dir="${dist.dir}/src" />
-        <copy todir="${dist.dir}/src" includeEmptyDirs="true">
-            <fileset dir="src" excludes="**/*.template **/docs/build/**/*" />
-        </copy>
-    </target>
-
-    <!-- ================================================================== -->
-    <!-- Make release tarball                                               -->
-    <!-- ================================================================== -->
-    <macrodef name="macro_tar" description="Worker Macro for tar">
-        <attribute name="param.destfile" />
-        <element name="param.listofitems" />
-        <sequential>
-            <tar compression="gzip" longfile="gnu" destfile="@{param.destfile}">
-                <param.listofitems />
-            </tar>
-        </sequential>
-    </macrodef>
-    <target name="tar" depends="package" description="Make release tarball">
-        <macro_tar param.destfile="${build.dir}/${final.name}.tar.gz">
-            <param.listofitems>
-                <tarfileset dir="${build.dir}" mode="664">
-                    <exclude name="${final.name}/bin/*" />
-                    <include name="${final.name}/**" />
-                </tarfileset>
-                <tarfileset dir="${build.dir}" mode="755">
-                    <include name="${final.name}/bin/*" />
-                </tarfileset>
-            </param.listofitems>
-        </macro_tar>
-    </target>
-
-    <target name="binary" depends="package" 
-    	description="Make tarball without source and documentation">
-        <macro_tar param.destfile="${build.dir}/${final.name}-bin.tar.gz">
-            <param.listofitems>
-                <tarfileset dir="${build.dir}" mode="664">
-                    <exclude name="${final.name}/bin/*" />
-                    <exclude name="${final.name}/src/**" />
-                    <exclude name="${final.name}/docs/**" />
-                    <include name="${final.name}/**" />
-                </tarfileset>
-                <tarfileset dir="${build.dir}" mode="755">
-                    <include name="${final.name}/bin/*" />
-                </tarfileset>
-            </param.listofitems>
-        </macro_tar>
-    </target>
-
-    <!-- ================================================================== -->
-    <!-- Doc                                                                -->
-    <!-- ================================================================== -->
-    <target name="docs" depends="forrest.check" description="Generate forrest-based documentation. To use, specify -Dforrest.home=&lt;base of Apache Forrest installation&gt; on the command line." if="forrest.home">
-        <exec dir="${docs.src}" executable="${forrest.home}/bin/forrest" 
-               failonerror="true">
-        	<env key="JAVA_HOME" value="${java5.home}"/>
-        </exec>
-        <copy todir="${build.docs}">
-          <fileset dir="${docs.src}/build/site/" />
-        </copy>
-    	<delete dir="${docs.src}/build/"/>
-    </target>
-
-    <target name="forrest.check" unless="forrest.home">
-        <fail message="'forrest.home' is not defined. Please pass -Dforrest.home=&lt;base of Apache Forrest installation&gt; to Ant on the command-line." />
-    </target>
-
-    <!-- Javadoc -->
-    <target name="javadoc" depends="cc-compile" description="Generate javadoc">
-        <mkdir dir="${build.javadoc}" />
-        <javadoc overview="${src.dir}/overview.html" packagenames="org.apache.hama.*" 
-        	    destdir="${build.javadoc}" author="true" version="true" use="true" 
-        	    windowtitle="${Name} ${version} API" doctitle="${Name} ${version} API" 
-        	    bottom="Copyright &amp;copy; ${year} The Apache Software Foundation">
-            <packageset dir="${src.dir}">
-                <include name="org/apache/**" />
-            </packageset>
-            <packageset dir="${src.gen.dir}">
-                <include name="org/apache/**" />
-            </packageset>
-            <link href="${javadoc.link.java}" />
-            <classpath>
-                <path refid="classpath" />
-                <pathelement path="${java.class.path}" />
-            </classpath>
-            <group title="${Name}" packages="org.apache.hama.*" />
-        </javadoc>
-    </target>
-
-    <!-- ================================================================== -->
-    <!-- Run unit tests                                                     -->
-    <!-- ================================================================== -->
-    <path id="test.classpath">
-        <pathelement location="${src.test}" />
-        <pathelement location="${build.test}" />
-        <path refid="classpath" />
-        <pathelement location="${build.dir}" />
-    </path>
-
-    <target name="compile-test" depends="compile">
-        <javac encoding="${build.encoding}" srcdir="${src.test}" 
-           includes="**/*.java" destdir="${build.test}" debug="${javac.debug}">
-            <classpath refid="test.classpath" />
-        </javac>
-        <jar jarfile="${build.dir}/${final.name}-test.jar">
-            <fileset dir="${build.test}" includes="org/**" />
-            <fileset dir="${build.classes}" />
-            <fileset dir="${src.test}" includes="**/*.properties" />
-            <manifest>
-              <attribute name="Main-Class" value="org/apache/hama/Benchmarks" />
-            </manifest>
-        </jar>
-    </target>
-
-    <target name="test" depends="compile-test, compile">
-        <junit printsummary="yes" showoutput="${test.output}" haltonfailure="no"
-              fork="yes" maxmemory="512m" errorProperty="tests.failed" 
-        	     failureProperty="tests.failed" timeout="${test.timeout}">
-            <classpath refid="test.classpath" />
-            <formatter type="${test.junit.output.format}" />
-            <batchtest todir="${build.report.tests}">
-                <fileset dir="${src.test}" includes="**/Test*.java" 
-                	 excludes="**/${test.exclude}.java" />
-            </batchtest>
-        </junit>
-        <fail if="tests.failed">Tests failed!</fail>
-    </target>
-
-    <target name="findbugs" depends="init, jar">
-        <findbugs home="${lib.dir}/findbugs" output="xml" 
-        	     outputFile="${build.report.findbugs}/hama-findbugs.xml" 
-               excludeFilter="${conf.dir}/findbugs-exclude-filter.xml"
-        	     auxClasspathRef="classpath">
-            <sourcePath path="${src.dir}" />
-            <class location="${build.dir}/${final.name}.jar" />
-        </findbugs>
-    </target>
-    
-    <target name="report" depends="findbugs,test"></target>
-    
-    <!-- ================================================================== -->
-    <!-- Clean.  Delete the build files, and their directories              -->
-    <!-- ================================================================== -->
-    <target name="clean">
-        <delete dir="${src.gen.dir}" />
-        <delete dir="${build.dir}" />
-    </target>
-</project>
+<?xml version="1.0"?>
+
+<!--
+   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.
+-->
+
+<project name="hama" default="jar">
+    <property name="version" value="0.2.0-dev" />
+    <property name="Name" value="Hama" />
+    <property name="final.name" value="hama-${version}" />
+    <property name="year" value="2009" />
+
+    <!-- Load all the default properties, and any the user wants    -->
+    <!-- to contribute (without having to type -D or edit this file -->
+    <property file="${user.home}/${name}.build.properties" />
+    <property file="${basedir}/build.properties" />
+
+    <property name="src.dir" location="${basedir}/src/java" />
+    <property name="src.gen.dir" location="${basedir}/src-gen" />
+    <property name="src.test" location="${basedir}/src/test" />
+    <property name="src.examples" location="${basedir}/src/examples" />
+
+    <property name="lib.dir" value="${basedir}/lib" />
+    <property name="conf.dir" value="${basedir}/conf" />
+    <property name="docs.dir" value="${basedir}/docs" />
+    <property name="docs.src" value="${basedir}/src/docs" />
+
+	<!-- javacc properties -->
+    <property name="javacc.home" value="${basedir}/lib" />
+
+    <property name="src.gen.parser.expression.dir" value="${src.gen.dir}/org/apache/hama/shell/parser/expression" />
+    <property name="src.gen.parser.script.dir" value="${src.gen.dir}/org/apache/hama/shell/parser/script" />
+
+	<!-- build properties -->
+	
+    <property name="test.output" value="no" />
+    <property name="test.timeout" value="600000" />
+
+    <property name="build.dir" location="${basedir}/build" />
+    <property name="build.lib" location="${build.dir}/lib" />
+    <property name="build.classes" location="${build.dir}/classes" />
+    <property name="build.test" location="${build.dir}/test" />
+    <property name="build.examples" location="${build.dir}/examples" />
+    <property name="build.docs" value="${build.dir}/docs/site" />
+    <property name="build.javadoc" value="${build.docs}/api" />
+    <property name="build.encoding" value="ISO-8859-1" />
+    <property name="build.src" value="${build.dir}/src" />
+    
+    <property name="build.report" value="${build.dir}/reports" />
+    <property name="build.report.findbugs" value="${build.report}/findbugs" />
+    <property name="build.report.tests" value="${build.report}/tests" />
+    
+    <property name="test.build.dir" value="${build.dir}/test" />
+    <property name="test.junit.output.format" value="plain" />
+
+    <property name="dist.dir" value="${build.dir}/${final.name}" />
+
+    <property name="javac.deprecation" value="off" />
+    <property name="javac.debug" value="on" />
+
+    <property name="javadoc.link.java" 
+                 value="http://java.sun.com/javase/6/docs/api/" />
+    <property name="javadoc.packages" value="org.apache.hama.*" />
+
+    <fileset id="lib.jars" dir="${basedir}" includes="lib/*.jar" />
+    <path id="classpath">
+        <fileset refid="lib.jars" />
+        <fileset dir="${lib.dir}/findbugs/">
+            <include name="*jar" />
+        </fileset>
+        <pathelement location="${build.classes}" />
+        <pathelement location="${conf.dir}" />
+    </path>
+
+    <taskdef name="findbugs" classpathref="classpath" 
+    	classname="edu.umd.cs.findbugs.anttask.FindBugsTask" />
+
+    <target name="init">
+        <mkdir dir="${src.gen.dir}" />
+        <mkdir dir="${src.gen.parser.script.dir}" />
+        <mkdir dir="${src.gen.parser.expression.dir}" />
+        <mkdir dir="${build.dir}" />
+        <mkdir dir="${build.classes}" />
+        <mkdir dir="${build.test}" />
+        <mkdir dir="${build.examples}" />
+        <mkdir dir="${build.report.findbugs}" />
+        <mkdir dir="${build.report.tests}" />
+        <!--Copy bin, lib, and conf. too-->
+        <mkdir dir="${build.lib}" />
+        <copy todir="${build.lib}">
+            <fileset dir="${lib.dir}" />
+        </copy>
+    </target>
+	
+	<!-- ================================================================== -->
+    <!-- Java Compiler Compiler, generate Parsers                           -->
+    <!-- ================================================================== -->
+    <target name="cc-compile" depends="init" description="Create and Compile Parser">
+        <jjtree target="${src.dir}/org/apache/hama/shell/parser/expression/HamaExpressionParser.jjt" outputdirectory="${src.gen.parser.expression.dir}" javacchome="${javacc.home}" />
+        <javacc target="${src.gen.parser.expression.dir}/HamaExpressionParser.jj" outputdirectory="${src.gen.parser.expression.dir}" javacchome="${javacc.home}" />
+        <javacc target="${src.dir}/org/apache/hama/shell/parser/script/HamaScriptParser.jj" outputdirectory="${src.gen.parser.script.dir}" javacchome="${javacc.home}" />
+    </target>
+
+    <target name="compile" depends="init, cc-compile">
+        <!--Compile whats under src and generated java classes made from jsp-->
+        <mkdir dir="${build.src}" />
+        <javac encoding="${build.encoding}" 
+                srcdir="${src.dir};${src.gen.dir};${build.src}" includes="**/*.java" 
+        	destdir="${build.classes}" debug="${javac.debug}" 
+                deprecation="${javac.deprecation}">
+            <classpath refid="classpath" />
+        </javac>
+    </target>
+
+    <target name="compile-examples" depends="compile">
+        <javac encoding="${build.encoding}" srcdir="${src.examples}" 
+                includes="**/*.java" 
+        	destdir="${build.examples}" debug="${javac.debug}" 
+                deprecation="${javac.deprecation}">
+            <classpath refid="classpath" />
+        </javac>
+    </target>
+
+    <!-- Override jar target to specify main class -->
+    <target name="jar" depends="compile">
+        <jar jarfile="${build.dir}/${final.name}.jar" 
+              basedir="${build.classes}">
+            <manifest>
+                <attribute name="Main-Class" 
+                    value="org/apache/hama/shell/HamaShell" />
+            </manifest>
+        </jar>
+    </target>
+
+    <target name="examples" depends="jar, compile-examples" 
+    	description="Make the hama examples jar.">
+        <jar jarfile="${build.dir}/${final.name}-examples.jar" 
+                basedir="${build.examples}">
+            <manifest>
+                <attribute name="Main-Class" 
+                    value="org/apache/hama/examples/ExampleDriver" />
+            </manifest>
+        </jar>
+    </target>
+
+    <target name="package" depends="jar,javadoc,compile-test, examples" 
+    	description="Build distribution">
+        <mkdir dir="${dist.dir}" />
+        <copy todir="${dist.dir}" includeEmptyDirs="false" flatten="true">
+            <fileset dir="${build.dir}">
+                <include name="${final.name}.jar" />
+                <include name="${final.name}-test.jar" />
+            </fileset>
+        </copy>
+        <mkdir dir="${dist.dir}/lib" />
+        <copy todir="${dist.dir}/lib">
+            <fileset dir="${build.lib}" />
+        </copy>
+        <copy todir="${dist.dir}">
+            <fileset dir=".">
+                <include name="*.txt" />
+            </fileset>
+        </copy>
+        <mkdir dir="${dist.dir}/src" />
+        <copy todir="${dist.dir}/src" includeEmptyDirs="true">
+            <fileset dir="src" excludes="**/*.template **/docs/build/**/*" />
+        </copy>
+    </target>
+
+    <!-- ================================================================== -->
+    <!-- Make release tarball                                               -->
+    <!-- ================================================================== -->
+    <macrodef name="macro_tar" description="Worker Macro for tar">
+        <attribute name="param.destfile" />
+        <element name="param.listofitems" />
+        <sequential>
+            <tar compression="gzip" longfile="gnu" destfile="@{param.destfile}">
+                <param.listofitems />
+            </tar>
+        </sequential>
+    </macrodef>
+    <target name="tar" depends="package" description="Make release tarball">
+        <macro_tar param.destfile="${build.dir}/${final.name}.tar.gz">
+            <param.listofitems>
+                <tarfileset dir="${build.dir}" mode="664">
+                    <exclude name="${final.name}/bin/*" />
+                    <include name="${final.name}/**" />
+                </tarfileset>
+                <tarfileset dir="${build.dir}" mode="755">
+                    <include name="${final.name}/bin/*" />
+                </tarfileset>
+            </param.listofitems>
+        </macro_tar>
+    </target>
+
+    <target name="binary" depends="package" 
+    	description="Make tarball without source and documentation">
+        <macro_tar param.destfile="${build.dir}/${final.name}-bin.tar.gz">
+            <param.listofitems>
+                <tarfileset dir="${build.dir}" mode="664">
+                    <exclude name="${final.name}/bin/*" />
+                    <exclude name="${final.name}/src/**" />
+                    <exclude name="${final.name}/docs/**" />
+                    <include name="${final.name}/**" />
+                </tarfileset>
+                <tarfileset dir="${build.dir}" mode="755">
+                    <include name="${final.name}/bin/*" />
+                </tarfileset>
+            </param.listofitems>
+        </macro_tar>
+    </target>
+
+    <!-- ================================================================== -->
+    <!-- Doc                                                                -->
+    <!-- ================================================================== -->
+    <target name="docs" depends="forrest.check" description="Generate forrest-based documentation. To use, specify -Dforrest.home=&lt;base of Apache Forrest installation&gt; on the command line." if="forrest.home">
+        <exec dir="${docs.src}" executable="${forrest.home}/bin/forrest" 
+               failonerror="true">
+        	<env key="JAVA_HOME" value="${java5.home}"/>
+        </exec>
+        <copy todir="${build.docs}">
+          <fileset dir="${docs.src}/build/site/" />
+        </copy>
+    	<delete dir="${docs.src}/build/"/>
+    </target>
+
+    <target name="forrest.check" unless="forrest.home">
+        <fail message="'forrest.home' is not defined. Please pass -Dforrest.home=&lt;base of Apache Forrest installation&gt; to Ant on the command-line." />
+    </target>
+
+    <!-- Javadoc -->
+    <target name="javadoc" depends="cc-compile" description="Generate javadoc">
+        <mkdir dir="${build.javadoc}" />
+        <javadoc overview="${src.dir}/overview.html" packagenames="org.apache.hama.*" 
+        	    destdir="${build.javadoc}" author="true" version="true" use="true" 
+        	    windowtitle="${Name} ${version} API" doctitle="${Name} ${version} API" 
+        	    bottom="Copyright &amp;copy; ${year} The Apache Software Foundation">
+            <packageset dir="${src.dir}">
+                <include name="org/apache/**" />
+            </packageset>
+            <packageset dir="${src.gen.dir}">
+                <include name="org/apache/**" />
+            </packageset>
+            <link href="${javadoc.link.java}" />
+            <classpath>
+                <path refid="classpath" />
+                <pathelement path="${java.class.path}" />
+            </classpath>
+            <group title="${Name}" packages="org.apache.hama.*" />
+        </javadoc>
+    </target>
+
+    <!-- ================================================================== -->
+    <!-- Run unit tests                                                     -->
+    <!-- ================================================================== -->
+    <path id="test.classpath">
+        <pathelement location="${src.test}" />
+        <pathelement location="${build.test}" />
+        <path refid="classpath" />
+        <pathelement location="${build.dir}" />
+    </path>
+
+    <target name="compile-test" depends="compile">
+        <javac encoding="${build.encoding}" srcdir="${src.test}" 
+           includes="**/*.java" destdir="${build.test}" debug="${javac.debug}">
+            <classpath refid="test.classpath" />
+        </javac>
+        <jar jarfile="${build.dir}/${final.name}-test.jar">
+            <fileset dir="${build.test}" includes="org/**" />
+            <fileset dir="${build.classes}" />
+            <fileset dir="${src.test}" includes="**/*.properties" />
+            <manifest>
+              <attribute name="Main-Class" value="org/apache/hama/Benchmarks" />
+            </manifest>
+        </jar>
+    </target>
+
+    <target name="test" depends="compile-test, compile">
+        <junit printsummary="yes" showoutput="${test.output}" haltonfailure="no"
+              fork="yes" maxmemory="512m" errorProperty="tests.failed" 
+        	     failureProperty="tests.failed" timeout="${test.timeout}">
+            <classpath refid="test.classpath" />
+            <formatter type="${test.junit.output.format}" />
+            <batchtest todir="${build.report.tests}">
+                <fileset dir="${src.test}" includes="**/Test*.java" 
+                	 excludes="**/${test.exclude}.java" />
+            </batchtest>
+        </junit>
+        <fail if="tests.failed">Tests failed!</fail>
+    </target>
+
+    <target name="findbugs" depends="init, jar">
+        <findbugs home="${lib.dir}/findbugs" output="xml" 
+        	     outputFile="${build.report.findbugs}/hama-findbugs.xml" 
+               excludeFilter="${conf.dir}/findbugs-exclude-filter.xml"
+        	     auxClasspathRef="classpath">
+            <sourcePath path="${src.dir}" />
+            <class location="${build.dir}/${final.name}.jar" />
+        </findbugs>
+    </target>
+    
+    <target name="report" depends="findbugs,test"></target>
+    
+    <!-- ================================================================== -->
+    <!-- Clean.  Delete the build files, and their directories              -->
+    <!-- ================================================================== -->
+    <target name="clean">
+        <delete dir="${src.gen.dir}" />
+        <delete dir="${build.dir}" />
+    </target>
+</project>
https://github.com/apache/hama/raw/42584cd5328fc55a499d318dda6fefff6459242c/build.xml
c45e160c5f4258d11573be997351b4718cf43a73
modified
https://github.com/apache/hama/blob/42584cd5328fc55a499d318dda6fefff6459242c/src%2Fjava%2Forg%2Fapache%2Fhama%2FHamaAdminImpl.java
https://api.github.com/repos/apache/hama/contents/src%2Fjava%2Forg%2Fapache%2Fhama%2FHamaAdminImpl.java?ref=42584cd5328fc55a499d318dda6fefff6459242c
src/java/org/apache/hama/HamaAdminImpl.java
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.Result;
@@ -25,8 +25,10 @@
 import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.MasterNotRunningException;
 import org.apache.hadoop.hbase.RegionException;
+import org.apache.hadoop.hbase.client.Get;
 import org.apache.hadoop.hbase.client.HBaseAdmin;
 import org.apache.hadoop.hbase.client.HTable;
+import org.apache.hadoop.hbase.client.Result;
 import org.apache.hadoop.hbase.io.BatchUpdate;
 import org.apache.hadoop.hbase.io.Cell;
 import org.apache.hadoop.hbase.util.Bytes;
https://github.com/apache/hama/raw/42584cd5328fc55a499d318dda6fefff6459242c/src%2Fjava%2Forg%2Fapache%2Fhama%2FHamaAdminImpl.java
39568b43f7cfa5c02867b88ec49d851a7c954faf
modified
https://github.com/apache/hama/blob/42584cd5328fc55a499d318dda6fefff6459242c/src%2Fjava%2Forg%2Fapache%2Fhama%2Fmatrix%2FAbstractMatrix.java
https://api.github.com/repos/apache/hama/contents/src%2Fjava%2Forg%2Fapache%2Fhama%2Fmatrix%2FAbstractMatrix.java?ref=42584cd5328fc55a499d318dda6fefff6459242c
src/java/org/apache/hama/matrix/AbstractMatrix.java
      this.tableDesc.addFamily(new HColumnDescriptor(Bytes.toBytes(Constants.COLUMN)));
      this.tableDesc.addFamily(new HColumnDescriptor(Bytes.toBytes(Constants.ATTRIBUTE)));
      this.tableDesc.addFamily(new HColumnDescriptor(Bytes.toBytes(Constants.ALIASEFAMILY)));
      
      // It's a temporary data.
      this.tableDesc.addFamily(new HColumnDescriptor(Bytes.toBytes(Constants.BLOCK)));
     // the following families are used in JacobiEigenValue computation
      this.tableDesc.addFamily(new HColumnDescriptor(Bytes.toBytes(JacobiEigenValue.EI)));
      this.tableDesc.addFamily(new HColumnDescriptor(Bytes.toBytes(JacobiEigenValue.EICOL)));
      this.tableDesc.addFamily(new HColumnDescriptor(Bytes.toBytes(JacobiEigenValue.EIVEC)));
      
      /*
      */
@@ -143,6 +143,18 @@ protected void tryToCreateTable(String table_prefix) throws IOException {
   protected void create() throws IOException {
     // It should run only when table doesn't exist.
     if (!admin.tableExists(matrixPath)) {
+      this.tableDesc.addFamily(new HColumnDescriptor(Bytes.toBytes(Constants.COLUMN)));
+      this.tableDesc.addFamily(new HColumnDescriptor(Bytes.toBytes(Constants.ATTRIBUTE)));
+      this.tableDesc.addFamily(new HColumnDescriptor(Bytes.toBytes(Constants.ALIASEFAMILY)));
+      
+      // It's a temporary data.
+      this.tableDesc.addFamily(new HColumnDescriptor(Bytes.toBytes(Constants.BLOCK)));
+     // the following families are used in JacobiEigenValue computation
+      this.tableDesc.addFamily(new HColumnDescriptor(Bytes.toBytes(JacobiEigenValue.EI)));
+      this.tableDesc.addFamily(new HColumnDescriptor(Bytes.toBytes(JacobiEigenValue.EICOL)));
+      this.tableDesc.addFamily(new HColumnDescriptor(Bytes.toBytes(JacobiEigenValue.EIVEC)));
+      
+      /*
       this.tableDesc.addFamily(new HColumnDescriptor(Bytes
           .toBytes(Constants.COLUMN), 3, CompressionType.NONE, false, false,
           Integer.MAX_VALUE, HConstants.FOREVER, false));
@@ -162,7 +174,7 @@ protected void create() throws IOException {
       this.tableDesc.addFamily(new HColumnDescriptor(Bytes
           .toBytes(JacobiEigenValue.EIVEC), 10, CompressionType.NONE, false,
           false, Integer.MAX_VALUE, HConstants.FOREVER, false));
-
+      */
       LOG.info("Initializing the matrix storage.");
       this.admin.createTable(this.tableDesc);
       LOG.info("Create Matrix " + matrixPath);
https://github.com/apache/hama/raw/42584cd5328fc55a499d318dda6fefff6459242c/src%2Fjava%2Forg%2Fapache%2Fhama%2Fmatrix%2FAbstractMatrix.java
54d9308ec83d3eccadce44883b70f367b07cd939
modified
https://github.com/apache/hama/blob/42584cd5328fc55a499d318dda6fefff6459242c/src%2Fjava%2Forg%2Fapache%2Fhama%2Fmatrix%2FDenseMatrix.java
https://api.github.com/repos/apache/hama/contents/src%2Fjava%2Forg%2Fapache%2Fhama%2Fmatrix%2FDenseMatrix.java?ref=42584cd5328fc55a499d318dda6fefff6459242c
src/java/org/apache/hama/matrix/DenseMatrix.java
import org.apache.hama.matrix.Matrix.Norm;
@@ -59,7 +59,6 @@
 import org.apache.hama.mapred.RandomMatrixMap;
 import org.apache.hama.mapred.RandomMatrixReduce;
 import org.apache.hama.mapred.VectorInputFormat;
-import org.apache.hama.matrix.Matrix.Norm;
 import org.apache.hama.matrix.algebra.BlockMultiplyMap;
 import org.apache.hama.matrix.algebra.BlockMultiplyReduce;
 import org.apache.hama.matrix.algebra.DenseMatrixVectorMultMap;
https://github.com/apache/hama/raw/42584cd5328fc55a499d318dda6fefff6459242c/src%2Fjava%2Forg%2Fapache%2Fhama%2Fmatrix%2FDenseMatrix.java
3e70326f6b8dc2c970255fed8d5db15c57d53609
modified
https://github.com/apache/hama/blob/42584cd5328fc55a499d318dda6fefff6459242c/src%2Fjava%2Forg%2Fapache%2Fhama%2Fmatrix%2FSparseVector.java
https://api.github.com/repos/apache/hama/contents/src%2Fjava%2Forg%2Fapache%2Fhama%2Fmatrix%2FSparseVector.java?ref=42584cd5328fc55a499d318dda6fefff6459242c
src/java/org/apache/hama/matrix/SparseVector.java
/**
 * Copyright 2007 The Apache Software Foundation
 *
 * 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.hama.matrix;

import java.io.IOException;
import java.util.Map;

import org.apache.hadoop.hbase.io.RowResult;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.MapWritable;
import org.apache.hadoop.io.Writable;
import org.apache.hama.io.DoubleEntry;
import org.apache.log4j.Logger;

/**
 * This class represents a sparse vector.
 */
public class SparseVector extends AbstractVector implements Vector {
  static final Logger LOG = Logger.getLogger(SparseVector.class);

  public SparseVector() {
    this(new MapWritable());
  }

  public SparseVector(MapWritable m) {
    this.entries = m;
  }

  public SparseVector(RowResult row) {
    this.initMap(row);
  }

  @Override
  public Vector add(double alpha, Vector v) {
    if (alpha == 0)
      return this;

    for (Map.Entry<Writable, Writable> e : v.getEntries().entrySet()) {
      if (this.entries.containsKey(e.getKey())) {
        // add
        double value = alpha * ((DoubleEntry) e.getValue()).getValue()
            + this.get(((IntWritable) e.getKey()).get());
        this.entries.put(e.getKey(), new DoubleEntry(value));
      } else {
        // put
        double value = alpha * ((DoubleEntry) e.getValue()).getValue();
        this.entries.put(e.getKey(), new DoubleEntry(value));
      }
    }

    return this;
  }

  /**
   * x = v + x
   * 
   * @param v2
   * @return x = v + x
   */
  public SparseVector add(Vector v2) {

    for (Map.Entry<Writable, Writable> e : v2.getEntries().entrySet()) {
      int key = ((IntWritable) e.getKey()).get();
      if (this.entries.containsKey(e.getKey())) {
        this.add(key, ((DoubleEntry) e.getValue()).getValue());
      } else {
        this.set(key, ((DoubleEntry) e.getValue()).getValue());
      }
    }

    return this;
  }

  @Override
  public double dot(Vector v) {
    // TODO Auto-generated method stub
    return 0;
  }

  @Override
  public double norm(Norm type) {
    // TODO Auto-generated method stub
    return 0;
  }

  /**
   * v = alpha*v
   * 
   * @param alpha
   * @return v = alpha*v
   */
  public SparseVector scale(double alpha) {
    for (Map.Entry<Writable, Writable> e : this.entries.entrySet()) {
      this.entries.put(e.getKey(), new DoubleEntry(((DoubleEntry) e.getValue())
          .getValue()
          * alpha));
    }
    return this;
  }

  /**
   * Gets the value of index
   * 
   * @param index
   * @return the value of v(index)
   * @throws IOException
   */
  public double get(int index) {
    double value;
    try {
      value = ((DoubleEntry) this.entries.get(new IntWritable(index)))
          .getValue();
    } catch (NullPointerException e) { // returns zero if there is no value
      return 0;
    }

    return value;
  }

  /**
   * Sets the value of index
   * 
   * @param index
   * @param value
   */
  public void set(int index, double value) {
    // If entries are null, create new object
    if (this.entries == null) {
      this.entries = new MapWritable();
    }

    if (value != 0) // only stores non-zero element
      this.entries.put(new IntWritable(index), new DoubleEntry(value));
  }

  /**
   * Adds the value to v(index)
   * 
   * @param index
   * @param value
   */
  public void add(int index, double value) {
    set(index, get(index) + value);
  }

  /**
   * Sets the vector
   * 
   * @param v
   * @return x = v
   */
  public SparseVector set(Vector v) {
    return new SparseVector(v.getEntries());
  }

  @Override
  public Vector subVector(int i0, int i1) {
    // TODO Auto-generated method stub
    return null;
  }

  @Override
  public Vector set(double alpha, Vector v) {
    // TODO Auto-generated method stub
    return null;
  }

}
src/java/org/apache/hama/matrix/SparseVector.java
this(new MapWritable());
public SparseVector()
MapWritable m
src/java/org/apache/hama/matrix/SparseVector.java
this.entries = m;
public SparseVector(MapWritable m)
RowResult row
src/java/org/apache/hama/matrix/SparseVector.java
this.initMap(row);
public SparseVector(RowResult row)
double alpha  Vector v
src/java/org/apache/hama/matrix/SparseVector.java
if (alpha == 0)
      return this;

    for (Map.Entry<Writable, Writable> e : v.getEntries().entrySet()) {
      if (this.entries.containsKey(e.getKey())) {
        // add
        double value = alpha * ((DoubleEntry) e.getValue()).getValue()
            + this.get(((IntWritable) e.getKey()).get());
        this.entries.put(e.getKey(), new DoubleEntry(value));
Vector add(double alpha, Vector v)
Vector v2
src/java/org/apache/hama/matrix/SparseVector.java
for (Map.Entry<Writable, Writable> e : v2.getEntries().entrySet()) {
      int key = ((IntWritable) e.getKey()).get();
      if (this.entries.containsKey(e.getKey())) {
        this.add(key, ((DoubleEntry) e.getValue()).getValue());
SparseVector add(Vector v2)
Vector v
src/java/org/apache/hama/matrix/SparseVector.java
// TODO Auto-generated method stub
    return 0;
double dot(Vector v)
Norm type
src/java/org/apache/hama/matrix/SparseVector.java
// TODO Auto-generated method stub
    return 0;
double norm(Norm type)
double alpha
src/java/org/apache/hama/matrix/SparseVector.java
for (Map.Entry<Writable, Writable> e : this.entries.entrySet()) {
      this.entries.put(e.getKey(), new DoubleEntry(((DoubleEntry) e.getValue())
          .getValue()
          * alpha));
SparseVector scale(double alpha)
int index
src/java/org/apache/hama/matrix/SparseVector.java
double value;
    try {
      value = ((DoubleEntry) this.entries.get(new IntWritable(index)))
          .getValue();
double get(int index)
int index  double value
src/java/org/apache/hama/matrix/SparseVector.java
// If entries are null, create new object
    if (this.entries == null) {
      this.entries = new MapWritable();
void set(int index, double value)
int index  double value
src/java/org/apache/hama/matrix/SparseVector.java
set(index, get(index) + value);
void add(int index, double value)
Vector v
src/java/org/apache/hama/matrix/SparseVector.java
return new SparseVector(v.getEntries());
SparseVector set(Vector v)
int i0  int i1
src/java/org/apache/hama/matrix/SparseVector.java
// TODO Auto-generated method stub
    return null;
Vector subVector(int i0, int i1)
double alpha  Vector v
src/java/org/apache/hama/matrix/SparseVector.java
// TODO Auto-generated method stub
    return null;
Vector set(double alpha, Vector v)
/**
 * Copyright 2007 The Apache Software Foundation
 *
 * 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.hama.matrix;

import java.io.IOException;
import java.util.Map;

import org.apache.hadoop.hbase.io.RowResult;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.MapWritable;
import org.apache.hadoop.io.Writable;
import org.apache.hama.io.DoubleEntry;
import org.apache.hama.matrix.Vector.Norm;
import org.apache.log4j.Logger;

/**
 * This class represents a sparse vector.
 */
public class SparseVector extends AbstractVector implements Vector {
  static final Logger LOG = Logger.getLogger(SparseVector.class);

  public SparseVector() {
    this(new MapWritable());
  }

  public SparseVector(MapWritable m) {
    this.entries = m;
  }

  public SparseVector(RowResult row) {
    this.initMap(row);
  }

  @Override
  public Vector add(double alpha, Vector v) {
    if (alpha == 0)
      return this;

    for (Map.Entry<Writable, Writable> e : v.getEntries().entrySet()) {
      if (this.entries.containsKey(e.getKey())) {
        // add
        double value = alpha * ((DoubleEntry) e.getValue()).getValue()
            + this.get(((IntWritable) e.getKey()).get());
        this.entries.put(e.getKey(), new DoubleEntry(value));
      } else {
        // put
        double value = alpha * ((DoubleEntry) e.getValue()).getValue();
        this.entries.put(e.getKey(), new DoubleEntry(value));
      }
    }

    return this;
  }

  /**
   * x = v + x
   * 
   * @param v2
   * @return x = v + x
   */
  public SparseVector add(Vector v2) {

    for (Map.Entry<Writable, Writable> e : v2.getEntries().entrySet()) {
      int key = ((IntWritable) e.getKey()).get();
      if (this.entries.containsKey(e.getKey())) {
        this.add(key, ((DoubleEntry) e.getValue()).getValue());
      } else {
        this.set(key, ((DoubleEntry) e.getValue()).getValue());
      }
    }

    return this;
  }

  @Override
  public double dot(Vector v) {
    // TODO Auto-generated method stub
    return 0;
  }

  @Override
  public double norm(Norm type) {
    // TODO Auto-generated method stub
    return 0;
  }

  /**
   * v = alpha*v
   * 
   * @param alpha
   * @return v = alpha*v
   */
  public SparseVector scale(double alpha) {
    for (Map.Entry<Writable, Writable> e : this.entries.entrySet()) {
      this.entries.put(e.getKey(), new DoubleEntry(((DoubleEntry) e.getValue())
          .getValue()
          * alpha));
    }
    return this;
  }

  /**
   * Gets the value of index
   * 
   * @param index
   * @return the value of v(index)
   * @throws IOException
   */
  public double get(int index) {
    double value;
    try {
      value = ((DoubleEntry) this.entries.get(new IntWritable(index)))
          .getValue();
    } catch (NullPointerException e) { // returns zero if there is no value
      return 0;
    }

    return value;
  }

  /**
   * Sets the value of index
   * 
   * @param index
   * @param value
   */
  public void set(int index, double value) {
    // If entries are null, create new object
    if (this.entries == null) {
      this.entries = new MapWritable();
    }

    if (value != 0) // only stores non-zero element
      this.entries.put(new IntWritable(index), new DoubleEntry(value));
  }

  /**
   * Adds the value to v(index)
   * 
   * @param index
   * @param value
   */
  public void add(int index, double value) {
    set(index, get(index) + value);
  }

  /**
   * Sets the vector
   * 
   * @param v
   * @return x = v
   */
  public SparseVector set(Vector v) {
    return new SparseVector(v.getEntries());
  }

  @Override
  public Vector subVector(int i0, int i1) {
    // TODO Auto-generated method stub
    return null;
  }

  @Override
  public Vector set(double alpha, Vector v) {
    // TODO Auto-generated method stub
    return null;
  }

}

src/java/org/apache/hama/matrix/SparseVector.java
this(new MapWritable());
public SparseVector()
MapWritable m
src/java/org/apache/hama/matrix/SparseVector.java
this.entries = m;
public SparseVector(MapWritable m)
RowResult row
src/java/org/apache/hama/matrix/SparseVector.java
this.initMap(row);
public SparseVector(RowResult row)
double alpha  Vector v
src/java/org/apache/hama/matrix/SparseVector.java
if (alpha == 0)
      return this;

    for (Map.Entry<Writable, Writable> e : v.getEntries().entrySet()) {
      if (this.entries.containsKey(e.getKey())) {
        // add
        double value = alpha * ((DoubleEntry) e.getValue()).getValue()
            + this.get(((IntWritable) e.getKey()).get());
        this.entries.put(e.getKey(), new DoubleEntry(value));
Vector add(double alpha, Vector v)
Vector v2
src/java/org/apache/hama/matrix/SparseVector.java
for (Map.Entry<Writable, Writable> e : v2.getEntries().entrySet()) {
      int key = ((IntWritable) e.getKey()).get();
      if (this.entries.containsKey(e.getKey())) {
        this.add(key, ((DoubleEntry) e.getValue()).getValue());
SparseVector add(Vector v2)
Vector v
src/java/org/apache/hama/matrix/SparseVector.java
// TODO Auto-generated method stub
    return 0;
double dot(Vector v)
Norm type
src/java/org/apache/hama/matrix/SparseVector.java
// TODO Auto-generated method stub
    return 0;
double norm(Norm type)
double alpha
src/java/org/apache/hama/matrix/SparseVector.java
for (Map.Entry<Writable, Writable> e : this.entries.entrySet()) {
      this.entries.put(e.getKey(), new DoubleEntry(((DoubleEntry) e.getValue())
          .getValue()
          * alpha));
SparseVector scale(double alpha)
int index
src/java/org/apache/hama/matrix/SparseVector.java
double value;
    try {
      value = ((DoubleEntry) this.entries.get(new IntWritable(index)))
          .getValue();
double get(int index)
int index  double value
src/java/org/apache/hama/matrix/SparseVector.java
// If entries are null, create new object
    if (this.entries == null) {
      this.entries = new MapWritable();
void set(int index, double value)
int index  double value
src/java/org/apache/hama/matrix/SparseVector.java
set(index, get(index) + value);
void add(int index, double value)
Vector v
src/java/org/apache/hama/matrix/SparseVector.java
return new SparseVector(v.getEntries());
SparseVector set(Vector v)
int i0  int i1
src/java/org/apache/hama/matrix/SparseVector.java
// TODO Auto-generated method stub
    return null;
Vector subVector(int i0, int i1)
double alpha  Vector v
src/java/org/apache/hama/matrix/SparseVector.java
// TODO Auto-generated method stub
    return null;
Vector set(double alpha, Vector v)
@@ -1,186 +1,185 @@
-/**
- * Copyright 2007 The Apache Software Foundation
- *
- * 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.hama.matrix;
-
-import java.io.IOException;
-import java.util.Map;
-
-import org.apache.hadoop.hbase.io.RowResult;
-import org.apache.hadoop.io.IntWritable;
-import org.apache.hadoop.io.MapWritable;
-import org.apache.hadoop.io.Writable;
-import org.apache.hama.io.DoubleEntry;
-import org.apache.hama.matrix.Vector.Norm;
-import org.apache.log4j.Logger;
-
-/**
- * This class represents a sparse vector.
- */
-public class SparseVector extends AbstractVector implements Vector {
-  static final Logger LOG = Logger.getLogger(SparseVector.class);
-
-  public SparseVector() {
-    this(new MapWritable());
-  }
-
-  public SparseVector(MapWritable m) {
-    this.entries = m;
-  }
-
-  public SparseVector(RowResult row) {
-    this.initMap(row);
-  }
-
-  @Override
-  public Vector add(double alpha, Vector v) {
-    if (alpha == 0)
-      return this;
-
-    for (Map.Entry<Writable, Writable> e : v.getEntries().entrySet()) {
-      if (this.entries.containsKey(e.getKey())) {
-        // add
-        double value = alpha * ((DoubleEntry) e.getValue()).getValue()
-            + this.get(((IntWritable) e.getKey()).get());
-        this.entries.put(e.getKey(), new DoubleEntry(value));
-      } else {
-        // put
-        double value = alpha * ((DoubleEntry) e.getValue()).getValue();
-        this.entries.put(e.getKey(), new DoubleEntry(value));
-      }
-    }
-
-    return this;
-  }
-
-  /**
-   * x = v + x
-   * 
-   * @param v2
-   * @return x = v + x
-   */
-  public SparseVector add(Vector v2) {
-
-    for (Map.Entry<Writable, Writable> e : v2.getEntries().entrySet()) {
-      int key = ((IntWritable) e.getKey()).get();
-      if (this.entries.containsKey(e.getKey())) {
-        this.add(key, ((DoubleEntry) e.getValue()).getValue());
-      } else {
-        this.set(key, ((DoubleEntry) e.getValue()).getValue());
-      }
-    }
-
-    return this;
-  }
-
-  @Override
-  public double dot(Vector v) {
-    // TODO Auto-generated method stub
-    return 0;
-  }
-
-  @Override
-  public double norm(Norm type) {
-    // TODO Auto-generated method stub
-    return 0;
-  }
-
-  /**
-   * v = alpha*v
-   * 
-   * @param alpha
-   * @return v = alpha*v
-   */
-  public SparseVector scale(double alpha) {
-    for (Map.Entry<Writable, Writable> e : this.entries.entrySet()) {
-      this.entries.put(e.getKey(), new DoubleEntry(((DoubleEntry) e.getValue())
-          .getValue()
-          * alpha));
-    }
-    return this;
-  }
-
-  /**
-   * Gets the value of index
-   * 
-   * @param index
-   * @return the value of v(index)
-   * @throws IOException
-   */
-  public double get(int index) {
-    double value;
-    try {
-      value = ((DoubleEntry) this.entries.get(new IntWritable(index)))
-          .getValue();
-    } catch (NullPointerException e) { // returns zero if there is no value
-      return 0;
-    }
-
-    return value;
-  }
-
-  /**
-   * Sets the value of index
-   * 
-   * @param index
-   * @param value
-   */
-  public void set(int index, double value) {
-    // If entries are null, create new object
-    if (this.entries == null) {
-      this.entries = new MapWritable();
-    }
-
-    if (value != 0) // only stores non-zero element
-      this.entries.put(new IntWritable(index), new DoubleEntry(value));
-  }
-
-  /**
-   * Adds the value to v(index)
-   * 
-   * @param index
-   * @param value
-   */
-  public void add(int index, double value) {
-    set(index, get(index) + value);
-  }
-
-  /**
-   * Sets the vector
-   * 
-   * @param v
-   * @return x = v
-   */
-  public SparseVector set(Vector v) {
-    return new SparseVector(v.getEntries());
-  }
-
-  @Override
-  public Vector subVector(int i0, int i1) {
-    // TODO Auto-generated method stub
-    return null;
-  }
-
-  @Override
-  public Vector set(double alpha, Vector v) {
-    // TODO Auto-generated method stub
-    return null;
-  }
-
-}
+/**
+ * Copyright 2007 The Apache Software Foundation
+ *
+ * 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.hama.matrix;
+
+import java.io.IOException;
+import java.util.Map;
+
+import org.apache.hadoop.hbase.io.RowResult;
+import org.apache.hadoop.io.IntWritable;
+import org.apache.hadoop.io.MapWritable;
+import org.apache.hadoop.io.Writable;
+import org.apache.hama.io.DoubleEntry;
+import org.apache.log4j.Logger;
+
+/**
+ * This class represents a sparse vector.
+ */
+public class SparseVector extends AbstractVector implements Vector {
+  static final Logger LOG = Logger.getLogger(SparseVector.class);
+
+  public SparseVector() {
+    this(new MapWritable());
+  }
+
+  public SparseVector(MapWritable m) {
+    this.entries = m;
+  }
+
+  public SparseVector(RowResult row) {
+    this.initMap(row);
+  }
+
+  @Override
+  public Vector add(double alpha, Vector v) {
+    if (alpha == 0)
+      return this;
+
+    for (Map.Entry<Writable, Writable> e : v.getEntries().entrySet()) {
+      if (this.entries.containsKey(e.getKey())) {
+        // add
+        double value = alpha * ((DoubleEntry) e.getValue()).getValue()
+            + this.get(((IntWritable) e.getKey()).get());
+        this.entries.put(e.getKey(), new DoubleEntry(value));
+      } else {
+        // put
+        double value = alpha * ((DoubleEntry) e.getValue()).getValue();
+        this.entries.put(e.getKey(), new DoubleEntry(value));
+      }
+    }
+
+    return this;
+  }
+
+  /**
+   * x = v + x
+   * 
+   * @param v2
+   * @return x = v + x
+   */
+  public SparseVector add(Vector v2) {
+
+    for (Map.Entry<Writable, Writable> e : v2.getEntries().entrySet()) {
+      int key = ((IntWritable) e.getKey()).get();
+      if (this.entries.containsKey(e.getKey())) {
+        this.add(key, ((DoubleEntry) e.getValue()).getValue());
+      } else {
+        this.set(key, ((DoubleEntry) e.getValue()).getValue());
+      }
+    }
+
+    return this;
+  }
+
+  @Override
+  public double dot(Vector v) {
+    // TODO Auto-generated method stub
+    return 0;
+  }
+
+  @Override
+  public double norm(Norm type) {
+    // TODO Auto-generated method stub
+    return 0;
+  }
+
+  /**
+   * v = alpha*v
+   * 
+   * @param alpha
+   * @return v = alpha*v
+   */
+  public SparseVector scale(double alpha) {
+    for (Map.Entry<Writable, Writable> e : this.entries.entrySet()) {
+      this.entries.put(e.getKey(), new DoubleEntry(((DoubleEntry) e.getValue())
+          .getValue()
+          * alpha));
+    }
+    return this;
+  }
+
+  /**
+   * Gets the value of index
+   * 
+   * @param index
+   * @return the value of v(index)
+   * @throws IOException
+   */
+  public double get(int index) {
+    double value;
+    try {
+      value = ((DoubleEntry) this.entries.get(new IntWritable(index)))
+          .getValue();
+    } catch (NullPointerException e) { // returns zero if there is no value
+      return 0;
+    }
+
+    return value;
+  }
+
+  /**
+   * Sets the value of index
+   * 
+   * @param index
+   * @param value
+   */
+  public void set(int index, double value) {
+    // If entries are null, create new object
+    if (this.entries == null) {
+      this.entries = new MapWritable();
+    }
+
+    if (value != 0) // only stores non-zero element
+      this.entries.put(new IntWritable(index), new DoubleEntry(value));
+  }
+
+  /**
+   * Adds the value to v(index)
+   * 
+   * @param index
+   * @param value
+   */
+  public void add(int index, double value) {
+    set(index, get(index) + value);
+  }
+
+  /**
+   * Sets the vector
+   * 
+   * @param v
+   * @return x = v
+   */
+  public SparseVector set(Vector v) {
+    return new SparseVector(v.getEntries());
+  }
+
+  @Override
+  public Vector subVector(int i0, int i1) {
+    // TODO Auto-generated method stub
+    return null;
+  }
+
+  @Override
+  public Vector set(double alpha, Vector v) {
+    // TODO Auto-generated method stub
+    return null;
+  }
+
+}
https://github.com/apache/hama/raw/42584cd5328fc55a499d318dda6fefff6459242c/src%2Fjava%2Forg%2Fapache%2Fhama%2Fmatrix%2FSparseVector.java
5480a4915ff8d739e87ae67063ba5a53e23a2112
modified
https://github.com/apache/hama/blob/42584cd5328fc55a499d318dda6fefff6459242c/src%2Ftest%2Forg%2Fapache%2Fhama%2Fgraph%2FTestGraph.java
https://api.github.com/repos/apache/hama/contents/src%2Ftest%2Forg%2Fapache%2Fhama%2Fgraph%2FTestGraph.java?ref=42584cd5328fc55a499d318dda6fefff6459242c
src/test/org/apache/hama/graph/TestGraph.java
import java.io.UnsupportedEncodingException;
import org.apache.hama.HamaCluster;
public class TestGraph extends HamaCluster {
  /**
   * @throws UnsupportedEncodingException
   */
  public TestGraph() throws UnsupportedEncodingException {
    super();
  }
  public void setUp() throws Exception {
    super.setUp();
    conf = getConf();
    adj = new SparseGraph(conf);
import junit.extensions.TestSetup;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

import org.apache.hama.matrix.HCluster;
public class TestGraph extends TestCase {
  public static Test suite() {
    TestSetup setup = new TestSetup(new TestSuite(TestGraph.class)) {
      protected void setUp() throws Exception {
        HCluster hCluster = new HCluster();
        hCluster.setUp();
        conf = hCluster.getConf();
        adj = new SparseGraph(conf);
      }
      protected void tearDown() {
      }
    };
    return setup;
src/test/org/apache/hama/graph/TestGraph.java
TestSetup setup = new TestSetup(new TestSuite(TestGraph.class)) {
      protected void setUp() throws Exception {
        HCluster hCluster = new HCluster();
        hCluster.setUp();
        conf = hCluster.getConf();
        adj = new SparseGraph(conf);
Test suite()
src/test/org/apache/hama/graph/TestGraph.java
void tearDown()
@@ -20,38 +20,32 @@
 package org.apache.hama.graph;
 
 import java.io.IOException;
+import java.io.UnsupportedEncodingException;
 import java.util.HashMap;
 import java.util.Map;
 
-import junit.extensions.TestSetup;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
+import org.apache.hama.HamaCluster;
 import org.apache.hama.HamaConfiguration;
-import org.apache.hama.matrix.HCluster;
 import org.apache.log4j.Logger;
 
-public class TestGraph extends TestCase {
+public class TestGraph extends HamaCluster {
   static final Logger LOG = Logger.getLogger(TestGraph.class);
   private static HamaConfiguration conf;
   private static Graph adj;
   private static int[] result = new int[] { 4, 3, 2, 0, 1 };
 
-  public static Test suite() {
-    TestSetup setup = new TestSetup(new TestSuite(TestGraph.class)) {
-      protected void setUp() throws Exception {
-        HCluster hCluster = new HCluster();
-        hCluster.setUp();
 
-        conf = hCluster.getConf();
-        adj = new SparseGraph(conf);
-      }
+  /**
+   * @throws UnsupportedEncodingException
+   */
+  public TestGraph() throws UnsupportedEncodingException {
+    super();
+  }
 
-      protected void tearDown() {
-      }
-    };
-    return setup;
+  public void setUp() throws Exception {
+    super.setUp();
+    conf = getConf();
+    adj = new SparseGraph(conf);
   }
 
   public void testAddEdge() throws IOException {
https://github.com/apache/hama/raw/42584cd5328fc55a499d318dda6fefff6459242c/src%2Ftest%2Forg%2Fapache%2Fhama%2Fgraph%2FTestGraph.java
3a22f64e33cbab0acadaf146bbb70b07f1698271
modified
https://github.com/apache/hama/blob/42584cd5328fc55a499d318dda6fefff6459242c/src%2Ftest%2Forg%2Fapache%2Fhama%2Fmapred%2FTestBlockMatrixMapReduce.java
https://api.github.com/repos/apache/hama/contents/src%2Ftest%2Forg%2Fapache%2Fhama%2Fmapred%2FTestBlockMatrixMapReduce.java?ref=42584cd5328fc55a499d318dda6fefff6459242c
src/test/org/apache/hama/mapred/TestBlockMatrixMapReduce.java
/**
 * Copyright 2007 The Apache Software Foundation
 *
 * 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.hama.mapred;

import java.io.IOException;

import org.apache.hama.HamaCluster;
import org.apache.hama.matrix.DenseMatrix;
import org.apache.log4j.Logger;

public class TestBlockMatrixMapReduce extends HamaCluster {
  static final Logger LOG = Logger.getLogger(TestBlockMatrixMapReduce.class);
  static final int SIZE = 32;

  /** constructor */
  public TestBlockMatrixMapReduce() {
    super();
  }

  public void testBlockMatrixMapReduce() throws IOException,
      ClassNotFoundException {
    DenseMatrix m1 = DenseMatrix.random(conf, SIZE, SIZE);
    DenseMatrix m2 = DenseMatrix.random(conf, SIZE, SIZE);

    DenseMatrix c = (DenseMatrix) m1.mult(m2, 16);

    double[][] mem = new double[SIZE][SIZE];
    for (int i = 0; i < SIZE; i++) {
      for (int j = 0; j < SIZE; j++) {
        for (int k = 0; k < SIZE; k++) {
          mem[i][k] += m1.get(i, j) * m2.get(j, k);
        }
      }
    }

    for (int i = 0; i < SIZE; i++) {
      for (int j = 0; j < SIZE; j++) {
        double gap = (mem[i][j] - c.get(i, j));
        assertTrue(gap < 0.000001 || gap < -0.000001);
      }
    }
  }
}
src/test/org/apache/hama/mapred/TestBlockMatrixMapReduce.java
super();
public TestBlockMatrixMapReduce()
/**
 * Copyright 2007 The Apache Software Foundation
 *
 * 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.hama.mapred;

import java.io.IOException;

import org.apache.hama.matrix.DenseMatrix;
import org.apache.hama.matrix.HCluster;
import org.apache.log4j.Logger;

public class TestBlockMatrixMapReduce extends HCluster {
  static final Logger LOG = Logger.getLogger(TestBlockMatrixMapReduce.class);
  static final int SIZE = 32;

  /** constructor */
  public TestBlockMatrixMapReduce() {
    super();
  }

  public void testBlockMatrixMapReduce() throws IOException,
      ClassNotFoundException {
    DenseMatrix m1 = DenseMatrix.random(conf, SIZE, SIZE);
    DenseMatrix m2 = DenseMatrix.random(conf, SIZE, SIZE);

    DenseMatrix c = (DenseMatrix) m1.mult(m2, 16);

    double[][] mem = new double[SIZE][SIZE];
    for (int i = 0; i < SIZE; i++) {
      for (int j = 0; j < SIZE; j++) {
        for (int k = 0; k < SIZE; k++) {
          mem[i][k] += m1.get(i, j) * m2.get(j, k);
        }
      }
    }

    for (int i = 0; i < SIZE; i++) {
      for (int j = 0; j < SIZE; j++) {
        double gap = (mem[i][j] - c.get(i, j));
        assertTrue(gap < 0.000001 || gap < -0.000001);
      }
    }
  }
}

src/test/org/apache/hama/mapred/TestBlockMatrixMapReduce.java
super();
public TestBlockMatrixMapReduce()
@@ -1,60 +1,60 @@
-/**
- * Copyright 2007 The Apache Software Foundation
- *
- * 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.hama.mapred;
-
-import java.io.IOException;
-
-import org.apache.hama.matrix.DenseMatrix;
-import org.apache.hama.matrix.HCluster;
-import org.apache.log4j.Logger;
-
-public class TestBlockMatrixMapReduce extends HCluster {
-  static final Logger LOG = Logger.getLogger(TestBlockMatrixMapReduce.class);
-  static final int SIZE = 32;
-
-  /** constructor */
-  public TestBlockMatrixMapReduce() {
-    super();
-  }
-
-  public void testBlockMatrixMapReduce() throws IOException,
-      ClassNotFoundException {
-    DenseMatrix m1 = DenseMatrix.random(conf, SIZE, SIZE);
-    DenseMatrix m2 = DenseMatrix.random(conf, SIZE, SIZE);
-
-    DenseMatrix c = (DenseMatrix) m1.mult(m2, 16);
-
-    double[][] mem = new double[SIZE][SIZE];
-    for (int i = 0; i < SIZE; i++) {
-      for (int j = 0; j < SIZE; j++) {
-        for (int k = 0; k < SIZE; k++) {
-          mem[i][k] += m1.get(i, j) * m2.get(j, k);
-        }
-      }
-    }
-
-    for (int i = 0; i < SIZE; i++) {
-      for (int j = 0; j < SIZE; j++) {
-        double gap = (mem[i][j] - c.get(i, j));
-        assertTrue(gap < 0.000001 || gap < -0.000001);
-      }
-    }
-  }
-}
+/**
+ * Copyright 2007 The Apache Software Foundation
+ *
+ * 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.hama.mapred;
+
+import java.io.IOException;
+
+import org.apache.hama.HamaCluster;
+import org.apache.hama.matrix.DenseMatrix;
+import org.apache.log4j.Logger;
+
+public class TestBlockMatrixMapReduce extends HamaCluster {
+  static final Logger LOG = Logger.getLogger(TestBlockMatrixMapReduce.class);
+  static final int SIZE = 32;
+
+  /** constructor */
+  public TestBlockMatrixMapReduce() {
+    super();
+  }
+
+  public void testBlockMatrixMapReduce() throws IOException,
+      ClassNotFoundException {
+    DenseMatrix m1 = DenseMatrix.random(conf, SIZE, SIZE);
+    DenseMatrix m2 = DenseMatrix.random(conf, SIZE, SIZE);
+
+    DenseMatrix c = (DenseMatrix) m1.mult(m2, 16);
+
+    double[][] mem = new double[SIZE][SIZE];
+    for (int i = 0; i < SIZE; i++) {
+      for (int j = 0; j < SIZE; j++) {
+        for (int k = 0; k < SIZE; k++) {
+          mem[i][k] += m1.get(i, j) * m2.get(j, k);
+        }
+      }
+    }
+
+    for (int i = 0; i < SIZE; i++) {
+      for (int j = 0; j < SIZE; j++) {
+        double gap = (mem[i][j] - c.get(i, j));
+        assertTrue(gap < 0.000001 || gap < -0.000001);
+      }
+    }
+  }
+}
https://github.com/apache/hama/raw/42584cd5328fc55a499d318dda6fefff6459242c/src%2Ftest%2Forg%2Fapache%2Fhama%2Fmapred%2FTestBlockMatrixMapReduce.java
96419f3cee20b7fd3167f286812a23d740564721
modified
https://github.com/apache/hama/blob/42584cd5328fc55a499d318dda6fefff6459242c/src%2Ftest%2Forg%2Fapache%2Fhama%2Fmapred%2FTestRandomMatrixMapReduce.java
https://api.github.com/repos/apache/hama/contents/src%2Ftest%2Forg%2Fapache%2Fhama%2Fmapred%2FTestRandomMatrixMapReduce.java?ref=42584cd5328fc55a499d318dda6fefff6459242c
src/test/org/apache/hama/mapred/TestRandomMatrixMapReduce.java
import org.apache.hama.HamaCluster;
public class TestRandomMatrixMapReduce extends HamaCluster {
import org.apache.hama.matrix.HCluster;
public class TestRandomMatrixMapReduce extends HCluster {
@@ -21,12 +21,12 @@
 
 import java.io.IOException;
 
+import org.apache.hama.HamaCluster;
 import org.apache.hama.matrix.DenseMatrix;
-import org.apache.hama.matrix.HCluster;
 import org.apache.hama.matrix.SparseMatrix;
 import org.apache.log4j.Logger;
 
-public class TestRandomMatrixMapReduce extends HCluster {
+public class TestRandomMatrixMapReduce extends HamaCluster {
   static final Logger LOG = Logger.getLogger(TestRandomMatrixMapReduce.class);
   
   public void testRandomMatrixMapReduce() throws IOException {
https://github.com/apache/hama/raw/42584cd5328fc55a499d318dda6fefff6459242c/src%2Ftest%2Forg%2Fapache%2Fhama%2Fmapred%2FTestRandomMatrixMapReduce.java
7c2979b382bb14adec6e4f892915ef7d9b8e0899
modified
https://github.com/apache/hama/blob/42584cd5328fc55a499d318dda6fefff6459242c/src%2Ftest%2Forg%2Fapache%2Fhama%2Fmatrix%2FMatrixTestCommon.java
https://api.github.com/repos/apache/hama/contents/src%2Ftest%2Forg%2Fapache%2Fhama%2Fmatrix%2FMatrixTestCommon.java?ref=42584cd5328fc55a499d318dda6fefff6459242c
src/test/org/apache/hama/matrix/MatrixTestCommon.java
/**
 * 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.hama.matrix;

import java.io.IOException;

class MatrixTestCommon {

  static double verifyNorm1(Matrix m1) throws IOException {
    double[] colSum = new double[m1.getColumns()];
    for (int j = 0; j < m1.getColumns(); j++) {
      for (int i = 0; i < m1.getRows(); i++) {
        colSum[j] += Math.abs(m1.get(i, j));
      }
    }

    double max = 0;
    for (int i = 0; i < colSum.length; i++) {
      max = Math.max(colSum[i], max);
    }
    return max;
  }

  static double verifyNormInfinity(Matrix m1) throws IOException {
    double[] rowSum = new double[m1.getRows()];
    for (int i = 0; i < m1.getRows(); i++) {
      for (int j = 0; j < m1.getColumns(); j++) {
        rowSum[i] += Math.abs(m1.get(i, j));
      }
    }

    double max = 0;
    for (int i = 0; i < rowSum.length; ++i)
      max = Math.max(rowSum[i], max);
    return max;
  }

  static double verifyNormMaxValue(Matrix m1) throws IOException {
    double max = 0;
    for (int i = 0; i < m1.getRows(); i++) {
      for (int j = 0; j < m1.getColumns(); j++) {
        max = Math.max(Math.abs(m1.get(i, j)), max);
      }
    }

    return max;
  }

  static double verifyNormFrobenius(Matrix m1) throws IOException {
    double sqrtSum = 0;
    for (int i = 0; i < m1.getRows(); i++) {
      for (int j = 0; j < m1.getColumns(); j++) {
        double cellValue = m1.get(i, j);
        sqrtSum += (cellValue * cellValue);
      }
    }
    return Math.sqrt(sqrtSum);
  }

}
/**
 * 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.hama.matrix;

import java.io.IOException;

class MatrixTestCommon {

  static double verifyNorm1(Matrix m1) throws IOException {
    double[] colSum = new double[m1.getColumns()];
    for (int j = 0; j < m1.getColumns(); j++) {
      for (int i = 0; i < m1.getRows(); i++) {
        colSum[j] += Math.abs(m1.get(i, j));
      }
    }
    
    double max = 0;
    for (int i=0; i < colSum.length; i++) {
      max = Math.max(colSum[i], max);
    }
    return max;
  }
  
  static double verifyNormInfinity(Matrix m1) throws IOException {
    double[] rowSum = new double[m1.getRows()];
    for (int i = 0; i < m1.getRows(); i++) {
      for (int j = 0; j < m1.getColumns(); j++) {
        rowSum[i] += Math.abs(m1.get(i, j));
      }
    }

    double max = 0;
    for (int i = 0; i < rowSum.length; ++i)
      max = Math.max(rowSum[i], max);
    return max;
  }
  
  static double verifyNormMaxValue(Matrix m1) throws IOException {
    double max = 0;
    for (int i = 0; i < m1.getRows(); i++) {
      for (int j = 0; j < m1.getColumns(); j++) {
        max = Math.max(Math.abs(m1.get(i, j)), max);
      }
    }
    
    return max;
  }
  
  static double verifyNormFrobenius(Matrix m1) throws IOException {
    double sqrtSum = 0;
    for (int i = 0; i < m1.getRows(); i++) {
      for (int j = 0; j < m1.getColumns(); j++) {
        double cellValue = m1.get(i, j);
        sqrtSum += ( cellValue * cellValue );
      }
    } 
    return Math.sqrt(sqrtSum);
  }
  
}

@@ -1,74 +1,74 @@
-/**
- * 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.hama.matrix;
-
-import java.io.IOException;
-
-class MatrixTestCommon {
-
-  static double verifyNorm1(Matrix m1) throws IOException {
-    double[] colSum = new double[m1.getColumns()];
-    for (int j = 0; j < m1.getColumns(); j++) {
-      for (int i = 0; i < m1.getRows(); i++) {
-        colSum[j] += Math.abs(m1.get(i, j));
-      }
-    }
-    
-    double max = 0;
-    for (int i=0; i < colSum.length; i++) {
-      max = Math.max(colSum[i], max);
-    }
-    return max;
-  }
-  
-  static double verifyNormInfinity(Matrix m1) throws IOException {
-    double[] rowSum = new double[m1.getRows()];
-    for (int i = 0; i < m1.getRows(); i++) {
-      for (int j = 0; j < m1.getColumns(); j++) {
-        rowSum[i] += Math.abs(m1.get(i, j));
-      }
-    }
-
-    double max = 0;
-    for (int i = 0; i < rowSum.length; ++i)
-      max = Math.max(rowSum[i], max);
-    return max;
-  }
-  
-  static double verifyNormMaxValue(Matrix m1) throws IOException {
-    double max = 0;
-    for (int i = 0; i < m1.getRows(); i++) {
-      for (int j = 0; j < m1.getColumns(); j++) {
-        max = Math.max(Math.abs(m1.get(i, j)), max);
-      }
-    }
-    
-    return max;
-  }
-  
-  static double verifyNormFrobenius(Matrix m1) throws IOException {
-    double sqrtSum = 0;
-    for (int i = 0; i < m1.getRows(); i++) {
-      for (int j = 0; j < m1.getColumns(); j++) {
-        double cellValue = m1.get(i, j);
-        sqrtSum += ( cellValue * cellValue );
-      }
-    } 
-    return Math.sqrt(sqrtSum);
-  }
-  
-}
+/**
+ * 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.hama.matrix;
+
+import java.io.IOException;
+
+class MatrixTestCommon {
+
+  static double verifyNorm1(Matrix m1) throws IOException {
+    double[] colSum = new double[m1.getColumns()];
+    for (int j = 0; j < m1.getColumns(); j++) {
+      for (int i = 0; i < m1.getRows(); i++) {
+        colSum[j] += Math.abs(m1.get(i, j));
+      }
+    }
+
+    double max = 0;
+    for (int i = 0; i < colSum.length; i++) {
+      max = Math.max(colSum[i], max);
+    }
+    return max;
+  }
+
+  static double verifyNormInfinity(Matrix m1) throws IOException {
+    double[] rowSum = new double[m1.getRows()];
+    for (int i = 0; i < m1.getRows(); i++) {
+      for (int j = 0; j < m1.getColumns(); j++) {
+        rowSum[i] += Math.abs(m1.get(i, j));
+      }
+    }
+
+    double max = 0;
+    for (int i = 0; i < rowSum.length; ++i)
+      max = Math.max(rowSum[i], max);
+    return max;
+  }
+
+  static double verifyNormMaxValue(Matrix m1) throws IOException {
+    double max = 0;
+    for (int i = 0; i < m1.getRows(); i++) {
+      for (int j = 0; j < m1.getColumns(); j++) {
+        max = Math.max(Math.abs(m1.get(i, j)), max);
+      }
+    }
+
+    return max;
+  }
+
+  static double verifyNormFrobenius(Matrix m1) throws IOException {
+    double sqrtSum = 0;
+    for (int i = 0; i < m1.getRows(); i++) {
+      for (int j = 0; j < m1.getColumns(); j++) {
+        double cellValue = m1.get(i, j);
+        sqrtSum += (cellValue * cellValue);
+      }
+    }
+    return Math.sqrt(sqrtSum);
+  }
+
+}
https://github.com/apache/hama/raw/42584cd5328fc55a499d318dda6fefff6459242c/src%2Ftest%2Forg%2Fapache%2Fhama%2Fmatrix%2FMatrixTestCommon.java
7c00eb66ef35f28a763649fb25b0b91e8ce6a138
modified
https://github.com/apache/hama/blob/42584cd5328fc55a499d318dda6fefff6459242c/src%2Ftest%2Forg%2Fapache%2Fhama%2Fmatrix%2FTestDenseMatrix.java
https://api.github.com/repos/apache/hama/contents/src%2Ftest%2Forg%2Fapache%2Fhama%2Fmatrix%2FTestDenseMatrix.java?ref=42584cd5328fc55a499d318dda6fefff6459242c
src/test/org/apache/hama/matrix/TestDenseMatrix.java
import java.io.UnsupportedEncodingException;
import org.apache.hama.HamaCluster;
public class TestDenseMatrix extends HamaCluster {
  private int SIZE = 10;
  private Matrix m1;
  private Matrix m2;
  private HamaConfiguration conf;
   * @throws UnsupportedEncodingException
  public TestDenseMatrix() throws UnsupportedEncodingException {
    super();
  public void setUp() throws Exception {
    super.setUp();
    conf = getConf();
    m1 = DenseMatrix.random(conf, SIZE, SIZE);
    m2 = DenseMatrix.random(conf, SIZE, SIZE);
  }
  public void testAddMult() throws IOException {
    Matrix m3 = DenseMatrix.random(conf, SIZE, SIZE);
    Matrix m4 = DenseMatrix.random(conf, SIZE - 2, SIZE - 2);
    try {
      m1.add(m4);
      fail("Matrix-Addition should be failed while rows and columns aren't same.");
    } catch (IOException e) {
      LOG.info(e.toString());
    try {
      m1.mult(m4);
      fail("Matrix-Mult should be failed while A.columns!=B.rows.");
    } catch (IOException e) {
      LOG.info(e.toString());
    
    double origin = m1.get(1, 1);
    m1.add(1, 1, 0.5);
    assertEquals(m1.get(1, 1), origin + 0.5);
    
    matrixAdd(m1, m2);
    multMatrixAdd(m1, m2, m3);
    matrixMult(m1, m2);
    addAlphaMatrix(m1, m2);
    
    getRowColumn();
    setRowColumn();
    setMatrix(m1);
    setAlphaMatrix(m1);
  public void matrixAdd(Matrix m1, Matrix m2) throws IOException {
  public void multMatrixAdd(Matrix m1, Matrix m2, Matrix m3) throws IOException {
    Matrix result = ((DenseMatrix) m1).add(m2, m3);


        assertEquals(result.get(i, j), m1.get(i, j) + m2.get(i, j)
            + m3.get(i, j));
  public void matrixMult(Matrix m1, Matrix m2) throws IOException {
  public void addAlphaMatrix(Matrix m1, Matrix m2) throws IOException {
    double value = m1.get(0, 0) + (m2.get(0, 0) * 0.1);
    Matrix result = m1.add(0.1, m2);
    assertEquals(value, result.get(0, 0));
  }
  
  public void setMatrix(Matrix m1) throws IOException {
  public void setAlphaMatrix(Matrix m1) throws IOException {


  public void getRowColumn() throws IOException {
    boolean ex = false;
    try {
      m1.get(SIZE + 1, SIZE + 1);
    } catch (ArrayIndexOutOfBoundsException e) {
      ex = true;
    }
    assertTrue(ex);
    assertTrue(m1.get(0, 0) > 0);
    Vector v = m1.getColumn(0);
    Iterator<Writable> it = v.iterator();
    int x = 0;
    while (it.hasNext()) {
      assertEquals(m1.get(x, 0), ((DoubleEntry) it.next()).getValue());
      x++;
    }
    m1.setRowLabel(0, "row1");
    assertEquals(m1.getRowLabel(0), "row1");
    assertEquals(m1.getRowLabel(1), null);

    m1.setColumnLabel(0, "column1");
    assertEquals(m1.getColumnLabel(0), "column1");
    assertEquals(m1.getColumnLabel(1), null);
  public void setRowColumn() throws IOException {
    Iterator<Writable> it2 = m1.getColumn(SIZE).iterator();
    int x = 0;
    while (it2.hasNext()) {
      assertEquals(entries[x], ((DoubleEntry) it2.next()).getValue());
      x++;
import junit.extensions.TestSetup;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

import org.apache.hadoop.hbase.client.HBaseAdmin;
import org.apache.hama.HamaAdmin;
import org.apache.hama.HamaAdminImpl;
import org.apache.hama.matrix.Matrix.Norm;
public class TestDenseMatrix extends TestCase {
  private static int SIZE = 10;
  private static Matrix m1;
  private static Matrix m2;
  private static Matrix m3;
  private static Matrix m4, m5;
  private final static String aliase1 = "matrix_aliase_A";
  private final static String aliase2 = "matrix_aliase_B";
  private static HamaConfiguration conf;
  private static HBaseAdmin admin;
  private static HamaAdmin hamaAdmin;

  public static Test suite() {
    TestSetup setup = new TestSetup(new TestSuite(TestDenseMatrix.class)) {
      protected void setUp() throws Exception {
        HCluster hCluster = new HCluster();
        hCluster.setUp();

        conf = hCluster.getConf();
        admin = new HBaseAdmin(conf);
        hamaAdmin = new HamaAdminImpl(conf, admin);

        m1 = DenseMatrix.random(hCluster.getConf(), SIZE, SIZE);
        m2 = DenseMatrix.random(hCluster.getConf(), SIZE, SIZE);
        m3 = DenseMatrix.random(hCluster.getConf(), SIZE, SIZE);
        m4 = DenseMatrix.random(hCluster.getConf(), SIZE-2, SIZE-2);
        m5 = DenseMatrix.random(hCluster.getConf(), SIZE, SIZE);
      }

      protected void tearDown() {
        try {
          closeTest();
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
    };
    return setup;
  }

  public static void closeTest() throws IOException {
    m1.close();
    m2.close();
  }

  public void testEntryAdd() throws IOException {
    double origin = m1.get(1, 1);
    m1.add(1, 1, 0.5);

    assertEquals(m1.get(1, 1), origin + 0.5);
  }

  public void testGet() throws IOException {
    boolean ex = false;
    try {
      m1.get(SIZE + 1, SIZE + 1);
    } catch (ArrayIndexOutOfBoundsException e) {
      ex = true;
    }
    assertTrue(ex);
    assertTrue(m1.get(0, 0) > 0);
  }
  
  public void testTranspose() throws IOException {
    DenseMatrix trans = (DenseMatrix) m1.transpose();
    for(int i = 0; i < trans.getRows(); i++) {
      for(int j = 0; j < trans.getColumns(); j++) {
        assertEquals(trans.get(i, j), m1.get(j, i));
      }
    }
  }
   * Column vector test.
   * 
   * @param rand
   * @throws IOException
  public void testGetColumn() throws IOException {
    Vector v = m1.getColumn(0);
    Iterator<Writable> it = v.iterator();
    int x = 0;
    while (it.hasNext()) {
      assertEquals(m1.get(x, 0), ((DoubleEntry) it.next()).getValue());
      x++;
    }
  public void testGetSetAttribute() throws IOException {
    m1.setRowLabel(0, "row1");
    assertEquals(m1.getRowLabel(0), "row1");
    assertEquals(m1.getRowLabel(1), null);

    m1.setColumnLabel(0, "column1");
    assertEquals(m1.getColumnLabel(0), "column1");
    assertEquals(m1.getColumnLabel(1), null);
  }
  public void testSubMatrix() throws IOException {
    SubMatrix a = m1.subMatrix(2, 4, 2, 5); // A : 3 * 4
    for (int i = 0; i < a.getRows(); i++) {
      for (int j = 0; j < a.getColumns(); j++) {
        assertEquals(a.get(i, j), m1.get(i + 2, j + 2));
      }
    }
    SubMatrix b = m2.subMatrix(0, 3, 0, 2); // B : 4 * 3
    SubMatrix c = a.mult(b);
    double[][] C = new double[3][3]; // A * B
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        for (int k = 0; k < 4; k++) {
          C[i][j] += m1.get(i + 2, k + 2) * m2.get(k, j);
        }
      }
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        assertEquals(C[i][j], c.get(i, j));
      }
  public void testMatrixAdd() throws IOException {
  public void testMultiMatrixAdd() throws IOException {
    Matrix result = ((DenseMatrix)m1).add(m2, m3);
    
    
        assertEquals(result.get(i, j), m1.get(i, j) + m2.get(i, j) + m3.get(i, j));
  public void testMatrixMult() throws IOException {
  public void testSetMatrix() throws IOException {
  public void testSetAlphaMatrix() throws IOException {
    
  
  public void testAddAlphaMatrix() throws IOException {
    double value = m1.get(0, 0) + (m2.get(0, 0) * 0.1);
    Matrix result = m1.add(0.1, m2);
    assertEquals(value, result.get(0, 0));
  }
  
  public void testNorm() throws IOException {
    double gap = 0.000001;
    
    double norm1 = m1.norm(Norm.One);
    double verify_norm1 = MatrixTestCommon.verifyNorm1(m1);
    gap = norm1 - verify_norm1;
    LOG.info("Norm One : gap " + gap);
    assertTrue(gap < 0.000001 && gap > -0.000001);
    
    double normInfinity = m1.norm(Norm.Infinity);
    double verify_normInf = MatrixTestCommon.verifyNormInfinity(m1);
    gap = normInfinity - verify_normInf;
    LOG.info("Norm Infinity : gap " + gap);
    assertTrue(gap < 0.000001 && gap > -0.000001);
    double normMaxValue = m1.norm(Norm.Maxvalue);
    double verify_normMV = MatrixTestCommon.verifyNormMaxValue(m1);
    gap = normMaxValue - verify_normMV;
    LOG.info("Norm MaxValue : gap " + gap);
    assertTrue(gap < 0.000001 && gap > -0.000001);
    double normFrobenius = m1.norm(Norm.Frobenius);
    double verify_normFrobenius = MatrixTestCommon.verifyNormFrobenius(m1);
    gap = normFrobenius - verify_normFrobenius;
    LOG.info("Norm Frobenius : " + normFrobenius + "(map/reduce) - " + verify_normFrobenius + " expected");
    LOG.info("Norm Frobenius : gap " + gap);
    assertTrue(gap < 0.000001 && gap > -0.000001);
  public void testSetRow() throws IOException {
  }

  public void testSetColumn() throws IOException {
    Vector v = new DenseVector();
    double[] entries = new double[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };

    for (int i = 0; i < SIZE; i++) {
      v.set(i, entries[i]);
    }
    Iterator<Writable> it = m1.getColumn(SIZE).iterator();

    int i = 0;
    while (it.hasNext()) {
      assertEquals(entries[i], ((DoubleEntry) it.next()).getValue());
      i++;
    }
  }

  public void testJacobiEigenValue() throws IOException {
    // copy Matrix m5 to the array
    double[][] S = new double[SIZE][SIZE];
    
    for (int i = 0; i < SIZE; i++) {
      for (int j = 0; j < SIZE; j++) {
        S[i][j] = m5.get(i, j);
      }
    }
    
    // do m/r jacobi eigen value computation
    DenseMatrix dm = (DenseMatrix)m5;
    dm.jacobiEigenValue(3);
    
    // do jacobi egien value over S array
    int i, j, k, l, m, state;
    double s, c, t, p, y;
    double e1, e2;
    // index array
    int[] ind = new int[SIZE];
    boolean[] changed = new boolean[SIZE];
    
    // output
    double[] e = new double[SIZE];
    double[][] E = new double[SIZE][SIZE];
    
    // init e & E; ind & changed
    for(i=0; i<SIZE; i++) {
      for(j=0; j<SIZE; j++) {
        E[i][j] = 0;
      }
      E[i][i] = 1;
    }
    
    state = SIZE;
    
    for(i=0; i<SIZE; i++) {
      ind[i] = maxind(S, i, SIZE); 
      e[i] = S[i][i];
      changed[i] = true;
    }
    
    int loops = 3;
    // next rotation
    while(state != 0 && loops > 0) {
      // find index(k, l) for pivot p
      m = 0;
      for(k = 1; k <= SIZE-2; k++) {
        if(Math.abs(S[m][ind[m]]) < Math.abs(S[k][ind[k]])) {
          m = k;
        }
      }
      
      k = m; l = ind[m]; p = S[k][l];
      
      // calculate c = cos, s = sin
      y = (e[l] - e[k]) / 2;
      t = Math.abs(y) + Math.sqrt(p * p + y * y);
      s = Math.sqrt(p * p + t * t);
      c = t / s;
      s = p / s;
      t = (p * p) / t;
      if(y < 0) {
        s = -s;
        t = -t;
      }
      
      S[k][l] = 0.0;
      state = update(e, changed, k, -t, state);
      state = update(e, changed, l, t, state);
      
      for(i = 0; i <= k-1; i++) 
        rotate(S, i, k, i, l, c, s);
      
      for(i = l+1; i < SIZE; i++)
        rotate(S, k, i, l, i, c, s);
      
      for(i = k+1; i <= l-1; i++)
        rotate(S, k, i, i, l, c, s);
      
      // rotate eigenvectors
      for(i = 0; i < SIZE; i++) {
        e1 = E[k][i];
        e2 = E[l][i];
        
        E[k][i] = c * e1 - s * e2;
        E[l][i] = s * e1 + c * e2;
      }
      
      ind[k] = maxind(S, k, SIZE);
      ind[l] = maxind(S, l, SIZE);
      
      loops --;
    }
    
    // verify the results
    assertTrue(dm.verifyEigenValue(e, E));
  }

  public void testEnsureForAddition() {
    try {
      m1.add(m4);
      fail("Matrix-Addition should be failed while rows and columns aren't same.");
    } catch (IOException e) {
      LOG.info(e.toString());
    }
  }

  public void testEnsureForMultiplication() {
    try {
      m1.mult(m4);
      fail("Matrix-Mult should be failed while A.columns!=B.rows.");
    } catch (IOException e) {
      LOG.info(e.toString());
    }
  }
  
  public void testLoadSave() throws IOException {
    String path1 = m1.getPath();
    // save m1 to aliase1
    m1.save(aliase1);
    // load matrix m1 using aliase1
    DenseMatrix loadTest = new DenseMatrix(conf, aliase1, false);
    for (int i = 0; i < SIZE; i++) {
      for (int j = 0; j < SIZE; j++) {
        assertEquals(m1.get(i, j), loadTest.get(i, j));
      }
    }

    assertEquals(path1, loadTest.getPath());
    // close loadTest, it just disconnect to the table but didn't delete it.
    loadTest.close();

    // try to close m1 & load matrix m1 using aliase1 again.
    m1.close();
    DenseMatrix loadTest2 = new DenseMatrix(conf, aliase1, false);
    assertEquals(path1, loadTest2.getPath());
    // remove aliase1
    // because loadTest2 connect the aliase1, so we just remove aliase entry
    // but didn't delete the table.
    hamaAdmin.delete(aliase1);
    assertEquals(true, admin.tableExists(path1));
    // close loadTest2, because it is the last one who reference table 'path1'
    // it will do the gc!
    loadTest2.close();
    assertEquals(false, admin.tableExists(path1));

    // if we try to load non-existed matrix using aliase name, it should fail.
    DenseMatrix loadTest3 = null;
    try {
      loadTest3 = new DenseMatrix(conf, aliase1, false);
      fail("Try to load a non-existed matrix should fail!");
    } catch (IOException e) {

    } finally {
      if (loadTest3 != null)
        loadTest3.close();
  
  public void testForceCreate() throws IOException {
    String path2 = m2.getPath();
    // save m2 to aliase2
    m2.save(aliase2);
    // load matrix m2 using aliase2
    DenseMatrix loadTest = new DenseMatrix(conf, aliase2, false);

    for (int i = 0; i < loadTest.getRows(); i++) {
      for (int j = 0; j < loadTest.getColumns(); j++) {
        assertEquals(m2.get(i, j), loadTest.get(i, j));
      }
    }

    assertEquals(path2, loadTest.getPath());

    Matrix test = hamaAdmin.getMatrix(aliase2);
    assertEquals(test.getType(), "DenseMatrix");
    
    // force to create matrix loadTest2 using aliasename 'aliase2'
    DenseMatrix loadTest2 = new DenseMatrix(conf, aliase2, true);
    String loadPath2 = loadTest2.getPath();
    assertFalse(path2.equals(loadPath2));
    assertEquals(loadPath2, hamaAdmin.getPath(aliase2));
    assertFalse(path2.equals(hamaAdmin.getPath(aliase2)));

    // try to close m2 & loadTest, it table will be deleted finally
    m2.close();
    assertEquals(true, admin.tableExists(path2));
    loadTest.close();
    assertEquals(false, admin.tableExists(path2));

    // remove 'aliase2' & close loadTest2
    loadTest2.close();
    assertEquals(true, admin.tableExists(loadPath2));
    hamaAdmin.delete(aliase2);
    assertEquals(false, admin.tableExists(loadPath2));
  }
  
  //index of largest off-diagonal element in row k
  int maxind(double[][] S, int row, int size) {
    int m = row + 1;
    for(int i=row + 2; i<size; i++) {
      if(Math.abs(S[row][i]) > Math.abs(S[row][m]))
        m = i;
    }
    return m;
  }
  
  int update(double[] e, boolean[] changed, int row, double value, int state) {
    double y = e[row];
    e[row] += value;
    
    if(changed[row] && y == e[row]) {
      changed[row] = false;
      return state - 1;
    } else if(!changed[row] && y != e[row]) {
      changed[row] = true;
      return state + 1;
    } else
      return state;
  }
  
  void rotate(double[][] S, int k, int l, int i, int j, double c, double s) {
    double s1 = S[k][l], s2 = S[i][j];
    S[k][l] = c * s1 - s * s2;
    S[i][j] = s * s1 + c * s2;
  }
src/test/org/apache/hama/matrix/TestDenseMatrix.java
TestSetup setup = new TestSetup(new TestSuite(TestDenseMatrix.class)) {
      protected void setUp() throws Exception {
        HCluster hCluster = new HCluster();
        hCluster.setUp();

        conf = hCluster.getConf();
        admin = new HBaseAdmin(conf);
        hamaAdmin = new HamaAdminImpl(conf, admin);

        m1 = DenseMatrix.random(hCluster.getConf(), SIZE, SIZE);
        m2 = DenseMatrix.random(hCluster.getConf(), SIZE, SIZE);
        m3 = DenseMatrix.random(hCluster.getConf(), SIZE, SIZE);
        m4 = DenseMatrix.random(hCluster.getConf(), SIZE-2, SIZE-2);
        m5 = DenseMatrix.random(hCluster.getConf(), SIZE, SIZE);
Test suite()
src/test/org/apache/hama/matrix/TestDenseMatrix.java
try {
          closeTest();
void tearDown()
int i = 0; i < 3; i++
src/test/org/apache/hama/matrix/TestDenseMatrix.java
for (int j = 0; j < 3; j++) {
        for (int k = 0; k < 4; k++) {
          C[i][j] += m1.get(i + 2, k + 2) * m2.get(k, j);
B
    for (int i = 0; i < 3; i++)
i=0; i<SIZE; i++
src/test/org/apache/hama/matrix/TestDenseMatrix.java
for(j=0; j<SIZE; j++) {
        E[i][j] = 0;
changed
    for(i=0; i<SIZE; i++)
state != 0 && loops > 0
src/test/org/apache/hama/matrix/TestDenseMatrix.java
// find index(k, l) for pivot p
      m = 0;
      for(k = 1; k <= SIZE-2; k++) {
        if(Math.abs(S[m][ind[m]]) < Math.abs(S[k][ind[k]])) {
          m = k;
rotation
    while(state != 0 && loops > 0)
i = 0; i < SIZE; i++
src/test/org/apache/hama/matrix/TestDenseMatrix.java
e1 = E[k][i];
        e2 = E[l][i];
        
        E[k][i] = c * e1 - s * e2;
        E[l][i] = s * e1 + c * e2;
eigenvectors
      for(i = 0; i < SIZE; i++)
src/test/org/apache/hama/matrix/TestDenseMatrix.java
try {
      m1.add(m4);
      fail("Matrix-Addition should be failed while rows and columns aren't same.");
void testEnsureForAddition()
src/test/org/apache/hama/matrix/TestDenseMatrix.java
try {
      m1.mult(m4);
      fail("Matrix-Mult should be failed while A.columns!=B.rows.");
void testEnsureForMultiplication()
double[][] S  int row  int size
src/test/org/apache/hama/matrix/TestDenseMatrix.java
int m = row + 1;
    for(int i=row + 2; i<size; i++) {
      if(Math.abs(S[row][i]) > Math.abs(S[row][m]))
        m = i;
int maxind(double[][] S, int row, int size)
double[] e  boolean[] changed  int row  double value  int state
src/test/org/apache/hama/matrix/TestDenseMatrix.java
double y = e[row];
    e[row] += value;
    
    if(changed[row] && y == e[row]) {
      changed[row] = false;
      return state - 1;
int update(double[] e, boolean[] changed, int row, double value, int state)
!changed[row] && y != e[row]
src/test/org/apache/hama/matrix/TestDenseMatrix.java
changed[row] = true;
      return state + 1;
else if(!changed[row] && y != e[row])
double[][] S  int k  int l  int i  int j  double c  double s
src/test/org/apache/hama/matrix/TestDenseMatrix.java
double s1 = S[k][l], s2 = S[i][j];
    S[k][l] = c * s1 - s * s2;
    S[i][j] = s * s1 + c * s2;
void rotate(double[][] S, int k, int l, int i, int j, double c, double s)
@@ -20,158 +20,80 @@
 package org.apache.hama.matrix;
 
 import java.io.IOException;
+import java.io.UnsupportedEncodingException;
 import java.util.Iterator;
 
-import junit.extensions.TestSetup;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.apache.hadoop.hbase.client.HBaseAdmin;
 import org.apache.hadoop.io.Writable;
-import org.apache.hama.HamaAdmin;
-import org.apache.hama.HamaAdminImpl;
+import org.apache.hama.HamaCluster;
 import org.apache.hama.HamaConfiguration;
 import org.apache.hama.io.DoubleEntry;
-import org.apache.hama.matrix.Matrix.Norm;
 import org.apache.hama.util.RandomVariable;
 import org.apache.log4j.Logger;
 
 /**
  * Matrix test
  */
-public class TestDenseMatrix extends TestCase {
+public class TestDenseMatrix extends HamaCluster {
   static final Logger LOG = Logger.getLogger(TestDenseMatrix.class);
-  private static int SIZE = 10;
-  private static Matrix m1;
-  private static Matrix m2;
-  private static Matrix m3;
-  private static Matrix m4, m5;
-  private final static String aliase1 = "matrix_aliase_A";
-  private final static String aliase2 = "matrix_aliase_B";
-  private static HamaConfiguration conf;
-  private static HBaseAdmin admin;
-  private static HamaAdmin hamaAdmin;
-
-  public static Test suite() {
-    TestSetup setup = new TestSetup(new TestSuite(TestDenseMatrix.class)) {
-      protected void setUp() throws Exception {
-        HCluster hCluster = new HCluster();
-        hCluster.setUp();
-
-        conf = hCluster.getConf();
-        admin = new HBaseAdmin(conf);
-        hamaAdmin = new HamaAdminImpl(conf, admin);
-
-        m1 = DenseMatrix.random(hCluster.getConf(), SIZE, SIZE);
-        m2 = DenseMatrix.random(hCluster.getConf(), SIZE, SIZE);
-        m3 = DenseMatrix.random(hCluster.getConf(), SIZE, SIZE);
-        m4 = DenseMatrix.random(hCluster.getConf(), SIZE-2, SIZE-2);
-        m5 = DenseMatrix.random(hCluster.getConf(), SIZE, SIZE);
-      }
-
-      protected void tearDown() {
-        try {
-          closeTest();
-        } catch (IOException e) {
-          e.printStackTrace();
-        }
-      }
-    };
-    return setup;
-  }
-
-  public static void closeTest() throws IOException {
-    m1.close();
-    m2.close();
-  }
-
-  public void testEntryAdd() throws IOException {
-    double origin = m1.get(1, 1);
-    m1.add(1, 1, 0.5);
-
-    assertEquals(m1.get(1, 1), origin + 0.5);
-  }
-
-  public void testGet() throws IOException {
-    boolean ex = false;
-    try {
-      m1.get(SIZE + 1, SIZE + 1);
-    } catch (ArrayIndexOutOfBoundsException e) {
-      ex = true;
-    }
-    assertTrue(ex);
-    assertTrue(m1.get(0, 0) > 0);
-  }
-  
-  public void testTranspose() throws IOException {
-    DenseMatrix trans = (DenseMatrix) m1.transpose();
-    for(int i = 0; i < trans.getRows(); i++) {
-      for(int j = 0; j < trans.getColumns(); j++) {
-        assertEquals(trans.get(i, j), m1.get(j, i));
-      }
-    }
-  }
+  private int SIZE = 10;
+  private Matrix m1;
+  private Matrix m2;
+  private HamaConfiguration conf;
 
   /**
-   * Column vector test.
-   * 
-   * @param rand
-   * @throws IOException
+   * @throws UnsupportedEncodingException
    */
-  public void testGetColumn() throws IOException {
-    Vector v = m1.getColumn(0);
-    Iterator<Writable> it = v.iterator();
-    int x = 0;
-    while (it.hasNext()) {
-      assertEquals(m1.get(x, 0), ((DoubleEntry) it.next()).getValue());
-      x++;
-    }
+  public TestDenseMatrix() throws UnsupportedEncodingException {
+    super();
   }
 
-  public void testGetSetAttribute() throws IOException {
-    m1.setRowLabel(0, "row1");
-    assertEquals(m1.getRowLabel(0), "row1");
-    assertEquals(m1.getRowLabel(1), null);
-
-    m1.setColumnLabel(0, "column1");
-    assertEquals(m1.getColumnLabel(0), "column1");
-    assertEquals(m1.getColumnLabel(1), null);
-  }
+  public void setUp() throws Exception {
+    super.setUp();
 
-  public void testSubMatrix() throws IOException {
-    SubMatrix a = m1.subMatrix(2, 4, 2, 5); // A : 3 * 4
-    for (int i = 0; i < a.getRows(); i++) {
-      for (int j = 0; j < a.getColumns(); j++) {
-        assertEquals(a.get(i, j), m1.get(i + 2, j + 2));
-      }
-    }
+    conf = getConf();
 
-    SubMatrix b = m2.subMatrix(0, 3, 0, 2); // B : 4 * 3
-    SubMatrix c = a.mult(b);
+    m1 = DenseMatrix.random(conf, SIZE, SIZE);
+    m2 = DenseMatrix.random(conf, SIZE, SIZE);
+  }
 
-    double[][] C = new double[3][3]; // A * B
-    for (int i = 0; i < 3; i++) {
-      for (int j = 0; j < 3; j++) {
-        for (int k = 0; k < 4; k++) {
-          C[i][j] += m1.get(i + 2, k + 2) * m2.get(k, j);
-        }
-      }
+  public void testAddMult() throws IOException {
+    Matrix m3 = DenseMatrix.random(conf, SIZE, SIZE);
+    Matrix m4 = DenseMatrix.random(conf, SIZE - 2, SIZE - 2);
+    try {
+      m1.add(m4);
+      fail("Matrix-Addition should be failed while rows and columns aren't same.");
+    } catch (IOException e) {
+      LOG.info(e.toString());
     }
 
-    for (int i = 0; i < 3; i++) {
-      for (int j = 0; j < 3; j++) {
-        assertEquals(C[i][j], c.get(i, j));
-      }
+    try {
+      m1.mult(m4);
+      fail("Matrix-Mult should be failed while A.columns!=B.rows.");
+    } catch (IOException e) {
+      LOG.info(e.toString());
     }
+    
+    double origin = m1.get(1, 1);
+    m1.add(1, 1, 0.5);
+    assertEquals(m1.get(1, 1), origin + 0.5);
+    
+    matrixAdd(m1, m2);
+    multMatrixAdd(m1, m2, m3);
+    matrixMult(m1, m2);
+    addAlphaMatrix(m1, m2);
+    
+    getRowColumn();
+    setRowColumn();
+    setMatrix(m1);
+    setAlphaMatrix(m1);
   }
 
   /**
    * Test matrices addition
    * 
    * @throws IOException
    */
-  public void testMatrixAdd() throws IOException {
+  public void matrixAdd(Matrix m1, Matrix m2) throws IOException {
     Matrix result = m1.add(m2);
 
     assertEquals(result.getRows(), SIZE);
@@ -193,15 +115,16 @@ public void testMatrixAdd() throws IOException {
     }
   }
 
-  public void testMultiMatrixAdd() throws IOException {
-    Matrix result = ((DenseMatrix)m1).add(m2, m3);
-    
+  public void multMatrixAdd(Matrix m1, Matrix m2, Matrix m3) throws IOException {
+    Matrix result = ((DenseMatrix) m1).add(m2, m3);
+
     assertEquals(result.getRows(), SIZE);
     assertEquals(result.getColumns(), SIZE);
-    
+
     for (int i = 0; i < SIZE; i++) {
       for (int j = 0; j < SIZE; j++) {
-        assertEquals(result.get(i, j), m1.get(i, j) + m2.get(i, j) + m3.get(i, j));
+        assertEquals(result.get(i, j), m1.get(i, j) + m2.get(i, j)
+            + m3.get(i, j));
       }
     }
   }
@@ -211,7 +134,7 @@ public void testMultiMatrixAdd() throws IOException {
    * 
    * @throws IOException
    */
-  public void testMatrixMult() throws IOException {
+  public void matrixMult(Matrix m1, Matrix m2) throws IOException {
     Matrix result = m1.mult(m2);
 
     assertEquals(result.getRows(), SIZE);
@@ -220,7 +143,13 @@ public void testMatrixMult() throws IOException {
     verifyMultResult(m1, m2, result);
   }
 
-  public void testSetMatrix() throws IOException {
+  public void addAlphaMatrix(Matrix m1, Matrix m2) throws IOException {
+    double value = m1.get(0, 0) + (m2.get(0, 0) * 0.1);
+    Matrix result = m1.add(0.1, m2);
+    assertEquals(value, result.get(0, 0));
+  }
+  
+  public void setMatrix(Matrix m1) throws IOException {
     Matrix a = new DenseMatrix(conf, m1.getRows(), m1.getColumns());
     a.set(m1);
 
@@ -232,53 +161,45 @@ public void testSetMatrix() throws IOException {
     }
   }
 
-  public void testSetAlphaMatrix() throws IOException {
+  public void setAlphaMatrix(Matrix m1) throws IOException {
     Matrix a = new DenseMatrix(conf, m1.getRows(), m1.getColumns());
     a.set(0.5, m1);
-    
+
     for (int i = 0; i < 5; i++) {
       int x = RandomVariable.randInt(0, SIZE - 1);
       int y = RandomVariable.randInt(0, SIZE - 1);
       assertEquals(a.get(x, y), (m1.get(x, y) * 0.5));
     }
   }
-  
-  public void testAddAlphaMatrix() throws IOException {
-    double value = m1.get(0, 0) + (m2.get(0, 0) * 0.1);
-    Matrix result = m1.add(0.1, m2);
-    assertEquals(value, result.get(0, 0));
-  }
-  
-  public void testNorm() throws IOException {
-    double gap = 0.000001;
-    
-    double norm1 = m1.norm(Norm.One);
-    double verify_norm1 = MatrixTestCommon.verifyNorm1(m1);
-    gap = norm1 - verify_norm1;
-    LOG.info("Norm One : gap " + gap);
-    assertTrue(gap < 0.000001 && gap > -0.000001);
-    
-    double normInfinity = m1.norm(Norm.Infinity);
-    double verify_normInf = MatrixTestCommon.verifyNormInfinity(m1);
-    gap = normInfinity - verify_normInf;
-    LOG.info("Norm Infinity : gap " + gap);
-    assertTrue(gap < 0.000001 && gap > -0.000001);
+
+  public void getRowColumn() throws IOException {
+    boolean ex = false;
+    try {
+      m1.get(SIZE + 1, SIZE + 1);
+    } catch (ArrayIndexOutOfBoundsException e) {
+      ex = true;
+    }
+    assertTrue(ex);
+    assertTrue(m1.get(0, 0) > 0);
     
-    double normMaxValue = m1.norm(Norm.Maxvalue);
-    double verify_normMV = MatrixTestCommon.verifyNormMaxValue(m1);
-    gap = normMaxValue - verify_normMV;
-    LOG.info("Norm MaxValue : gap " + gap);
-    assertTrue(gap < 0.000001 && gap > -0.000001);
+    Vector v = m1.getColumn(0);
+    Iterator<Writable> it = v.iterator();
+    int x = 0;
+    while (it.hasNext()) {
+      assertEquals(m1.get(x, 0), ((DoubleEntry) it.next()).getValue());
+      x++;
+    }
     
-    double normFrobenius = m1.norm(Norm.Frobenius);
-    double verify_normFrobenius = MatrixTestCommon.verifyNormFrobenius(m1);
-    gap = normFrobenius - verify_normFrobenius;
-    LOG.info("Norm Frobenius : " + normFrobenius + "(map/reduce) - " + verify_normFrobenius + " expected");
-    LOG.info("Norm Frobenius : gap " + gap);
-    assertTrue(gap < 0.000001 && gap > -0.000001);
+    m1.setRowLabel(0, "row1");
+    assertEquals(m1.getRowLabel(0), "row1");
+    assertEquals(m1.getRowLabel(1), null);
+
+    m1.setColumnLabel(0, "column1");
+    assertEquals(m1.getColumnLabel(0), "column1");
+    assertEquals(m1.getColumnLabel(1), null);
   }
   
-  public void testSetRow() throws IOException {
+  public void setRowColumn() throws IOException {
     Vector v = new DenseVector();
     double[] entries = new double[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
 
@@ -294,224 +215,16 @@ public void testSetRow() throws IOException {
       assertEquals(entries[i], ((DoubleEntry) it.next()).getValue());
       i++;
     }
-  }
-
-  public void testSetColumn() throws IOException {
-    Vector v = new DenseVector();
-    double[] entries = new double[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
-
-    for (int i = 0; i < SIZE; i++) {
-      v.set(i, entries[i]);
-    }
 
     m1.setColumn(SIZE, v);
-    Iterator<Writable> it = m1.getColumn(SIZE).iterator();
-
-    int i = 0;
-    while (it.hasNext()) {
-      assertEquals(entries[i], ((DoubleEntry) it.next()).getValue());
-      i++;
-    }
-  }
-
-  public void testJacobiEigenValue() throws IOException {
-    // copy Matrix m5 to the array
-    double[][] S = new double[SIZE][SIZE];
-    
-    for (int i = 0; i < SIZE; i++) {
-      for (int j = 0; j < SIZE; j++) {
-        S[i][j] = m5.get(i, j);
-      }
-    }
-    
-    // do m/r jacobi eigen value computation
-    DenseMatrix dm = (DenseMatrix)m5;
-    dm.jacobiEigenValue(3);
-    
-    // do jacobi egien value over S array
-    int i, j, k, l, m, state;
-    double s, c, t, p, y;
-    double e1, e2;
-    // index array
-    int[] ind = new int[SIZE];
-    boolean[] changed = new boolean[SIZE];
-    
-    // output
-    double[] e = new double[SIZE];
-    double[][] E = new double[SIZE][SIZE];
-    
-    // init e & E; ind & changed
-    for(i=0; i<SIZE; i++) {
-      for(j=0; j<SIZE; j++) {
-        E[i][j] = 0;
-      }
-      E[i][i] = 1;
-    }
-    
-    state = SIZE;
-    
-    for(i=0; i<SIZE; i++) {
-      ind[i] = maxind(S, i, SIZE); 
-      e[i] = S[i][i];
-      changed[i] = true;
-    }
-    
-    int loops = 3;
-    // next rotation
-    while(state != 0 && loops > 0) {
-      // find index(k, l) for pivot p
-      m = 0;
-      for(k = 1; k <= SIZE-2; k++) {
-        if(Math.abs(S[m][ind[m]]) < Math.abs(S[k][ind[k]])) {
-          m = k;
-        }
-      }
-      
-      k = m; l = ind[m]; p = S[k][l];
-      
-      // calculate c = cos, s = sin
-      y = (e[l] - e[k]) / 2;
-      t = Math.abs(y) + Math.sqrt(p * p + y * y);
-      s = Math.sqrt(p * p + t * t);
-      c = t / s;
-      s = p / s;
-      t = (p * p) / t;
-      if(y < 0) {
-        s = -s;
-        t = -t;
-      }
-      
-      S[k][l] = 0.0;
-      state = update(e, changed, k, -t, state);
-      state = update(e, changed, l, t, state);
-      
-      for(i = 0; i <= k-1; i++) 
-        rotate(S, i, k, i, l, c, s);
-      
-      for(i = l+1; i < SIZE; i++)
-        rotate(S, k, i, l, i, c, s);
-      
-      for(i = k+1; i <= l-1; i++)
-        rotate(S, k, i, i, l, c, s);
-      
-      // rotate eigenvectors
-      for(i = 0; i < SIZE; i++) {
-        e1 = E[k][i];
-        e2 = E[l][i];
-        
-        E[k][i] = c * e1 - s * e2;
-        E[l][i] = s * e1 + c * e2;
-      }
-      
-      ind[k] = maxind(S, k, SIZE);
-      ind[l] = maxind(S, l, SIZE);
-      
-      loops --;
-    }
-    
-    // verify the results
-    assertTrue(dm.verifyEigenValue(e, E));
-  }
-
-  public void testEnsureForAddition() {
-    try {
-      m1.add(m4);
-      fail("Matrix-Addition should be failed while rows and columns aren't same.");
-    } catch (IOException e) {
-      LOG.info(e.toString());
-    }
-  }
-
-  public void testEnsureForMultiplication() {
-    try {
-      m1.mult(m4);
-      fail("Matrix-Mult should be failed while A.columns!=B.rows.");
-    } catch (IOException e) {
-      LOG.info(e.toString());
-    }
-  }
-  
-  public void testLoadSave() throws IOException {
-    String path1 = m1.getPath();
-    // save m1 to aliase1
-    m1.save(aliase1);
-    // load matrix m1 using aliase1
-    DenseMatrix loadTest = new DenseMatrix(conf, aliase1, false);
+    Iterator<Writable> it2 = m1.getColumn(SIZE).iterator();
 
-    for (int i = 0; i < SIZE; i++) {
-      for (int j = 0; j < SIZE; j++) {
-        assertEquals(m1.get(i, j), loadTest.get(i, j));
-      }
-    }
-
-    assertEquals(path1, loadTest.getPath());
-    // close loadTest, it just disconnect to the table but didn't delete it.
-    loadTest.close();
-
-    // try to close m1 & load matrix m1 using aliase1 again.
-    m1.close();
-    DenseMatrix loadTest2 = new DenseMatrix(conf, aliase1, false);
-    assertEquals(path1, loadTest2.getPath());
-    // remove aliase1
-    // because loadTest2 connect the aliase1, so we just remove aliase entry
-    // but didn't delete the table.
-    hamaAdmin.delete(aliase1);
-    assertEquals(true, admin.tableExists(path1));
-    // close loadTest2, because it is the last one who reference table 'path1'
-    // it will do the gc!
-    loadTest2.close();
-    assertEquals(false, admin.tableExists(path1));
-
-    // if we try to load non-existed matrix using aliase name, it should fail.
-    DenseMatrix loadTest3 = null;
-    try {
-      loadTest3 = new DenseMatrix(conf, aliase1, false);
-      fail("Try to load a non-existed matrix should fail!");
-    } catch (IOException e) {
-
-    } finally {
-      if (loadTest3 != null)
-        loadTest3.close();
+    int x = 0;
+    while (it2.hasNext()) {
+      assertEquals(entries[x], ((DoubleEntry) it2.next()).getValue());
+      x++;
     }
   }
-  
-  public void testForceCreate() throws IOException {
-    String path2 = m2.getPath();
-    // save m2 to aliase2
-    m2.save(aliase2);
-    // load matrix m2 using aliase2
-    DenseMatrix loadTest = new DenseMatrix(conf, aliase2, false);
-
-    for (int i = 0; i < loadTest.getRows(); i++) {
-      for (int j = 0; j < loadTest.getColumns(); j++) {
-        assertEquals(m2.get(i, j), loadTest.get(i, j));
-      }
-    }
-
-    assertEquals(path2, loadTest.getPath());
-
-    Matrix test = hamaAdmin.getMatrix(aliase2);
-    assertEquals(test.getType(), "DenseMatrix");
-    
-    // force to create matrix loadTest2 using aliasename 'aliase2'
-    DenseMatrix loadTest2 = new DenseMatrix(conf, aliase2, true);
-    String loadPath2 = loadTest2.getPath();
-    assertFalse(path2.equals(loadPath2));
-    assertEquals(loadPath2, hamaAdmin.getPath(aliase2));
-    assertFalse(path2.equals(hamaAdmin.getPath(aliase2)));
-
-    // try to close m2 & loadTest, it table will be deleted finally
-    m2.close();
-    assertEquals(true, admin.tableExists(path2));
-    loadTest.close();
-    assertEquals(false, admin.tableExists(path2));
-
-    // remove 'aliase2' & close loadTest2
-    loadTest2.close();
-    assertEquals(true, admin.tableExists(loadPath2));
-    hamaAdmin.delete(aliase2);
-    assertEquals(false, admin.tableExists(loadPath2));
-  }
 
   /**
    * Verifying multiplication result
@@ -539,34 +252,4 @@ private void verifyMultResult(Matrix m1, Matrix m2, Matrix result)
       }
     }
   }
-  
-  //index of largest off-diagonal element in row k
-  int maxind(double[][] S, int row, int size) {
-    int m = row + 1;
-    for(int i=row + 2; i<size; i++) {
-      if(Math.abs(S[row][i]) > Math.abs(S[row][m]))
-        m = i;
-    }
-    return m;
-  }
-  
-  int update(double[] e, boolean[] changed, int row, double value, int state) {
-    double y = e[row];
-    e[row] += value;
-    
-    if(changed[row] && y == e[row]) {
-      changed[row] = false;
-      return state - 1;
-    } else if(!changed[row] && y != e[row]) {
-      changed[row] = true;
-      return state + 1;
-    } else
-      return state;
-  }
-  
-  void rotate(double[][] S, int k, int l, int i, int j, double c, double s) {
-    double s1 = S[k][l], s2 = S[i][j];
-    S[k][l] = c * s1 - s * s2;
-    S[i][j] = s * s1 + c * s2;
-  }
 }
https://github.com/apache/hama/raw/42584cd5328fc55a499d318dda6fefff6459242c/src%2Ftest%2Forg%2Fapache%2Fhama%2Fmatrix%2FTestDenseMatrix.java
463f6c1a10d2611bb386cdb08ffac4a4cc167fe3
modified
https://github.com/apache/hama/blob/42584cd5328fc55a499d318dda6fefff6459242c/src%2Ftest%2Forg%2Fapache%2Fhama%2Fmatrix%2FTestDenseVector.java
https://api.github.com/repos/apache/hama/contents/src%2Ftest%2Forg%2Fapache%2Fhama%2Fmatrix%2FTestDenseVector.java?ref=42584cd5328fc55a499d318dda6fefff6459242c
src/test/org/apache/hama/matrix/TestDenseVector.java
/**
 * Copyright 2007 The Apache Software Foundation
 *
 * 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.hama.matrix;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.Iterator;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.io.Writable;
import org.apache.hama.HamaCluster;
import org.apache.hama.io.DoubleEntry;

public class TestDenseVector extends HamaCluster {
  final static Log LOG = LogFactory.getLog(TestDenseVector.class.getName());

  private final double cosine = 0.6978227007909176;
  private final double norm1 = 12.0;
  private final double norm2 = 6.782329983125268;
  private final double normInf = 5.0;
  private final double norm2Robust = 6.782329983125269;
  private double[][] values = { { 2, 5, 1, 4 }, { 4, 1, 3, 3 } };
  private DenseMatrix m1;
  private DenseVector v1;
  private DenseVector v2;
  private DenseVector smallSize = new DenseVector();

  /**
   * @throws UnsupportedEncodingException
   */
  public TestDenseVector() throws UnsupportedEncodingException {
    super();
  }

  public void setUp() throws Exception {
    super.setUp();

    m1 = new DenseMatrix(getConf(), 2, 4);

    for (int i = 0; i < 2; i++)
      for (int j = 0; j < 4; j++)
        m1.set(i, j, values[i][j]);

    v1 = m1.getRow(0);
    v2 = m1.getRow(1);
    smallSize.set(0, 0.5);
  }

  /**
   * @throws IOException 
   */
  public void testDenseVector() throws IOException {
    double cos = v1.dot(v2);
    assertEquals(cos, cosine);

    boolean except = false;
    try {
      v1.dot(smallSize);
    } catch (IndexOutOfBoundsException e) {
      except = true;
    }
    
    assertTrue(except);
    subVector();
        
    assertEquals(norm1, v1.norm(Vector.Norm.One));
    assertEquals(norm2, v1.norm(Vector.Norm.Two));
    assertEquals(normInf, v1.norm(Vector.Norm.Infinity));
    assertEquals(norm2Robust, v1.norm(Vector.Norm.TwoRobust));

    getSetTest();
    add();
    scalingTest();
    setTest();
    clear();
  }

  /**
   * Test scaling
   */
  public void scalingTest() {
    v2.scale(0.5);

    for (int i = 0; i < v2.size(); i++) {
      assertEquals(values[1][i] * 0.5, v2.get(i));
    }
  }

  /**
   * Test get/set methods
   * @throws IOException 
   */
  public void getSetTest() throws IOException {
    assertEquals(v1.get(0), values[0][0]);
    boolean ex = false;
    try {
      v1.get(5);
    } catch (NullPointerException e) {
      ex = true;
    }
    assertTrue(ex);
    assertEquals(m1.getColumn(0).size(), 2);
  }

  /**
   * Test add()
   */
  public void add() {
    v1.add(v2);
    int i = 0;
    Iterator<Writable> it = v1.iterator();
    while (it.hasNext()) {
      DoubleEntry c = (DoubleEntry) it.next();
      assertEquals(c.getValue(), values[0][i] + values[1][i]);
      i++;
    }

    v1.add(0.5, v2);
    int j = 0;
    Iterator<Writable> itt = v1.iterator();
    while (itt.hasNext()) {
      DoubleEntry c = (DoubleEntry) itt.next();
      assertEquals(c.getValue(), (values[0][j] + values[1][j]) + (0.5 * values[1][j]));
      j++;
    }
    
    double old = v1.get(0);
    v1.add(0, norm1);
    assertEquals(v1.get(0), old + norm1);
    
    boolean except = false;
    try {
      v1.add(smallSize);
    } catch (IndexOutOfBoundsException e) {
      except = true;
    }
    
    assertTrue(except);
    
    except = false;
    try {
      v1.add(0.6, smallSize);
    } catch (IndexOutOfBoundsException e) {
      except = true;
    }
    
    assertTrue(except);
  }
  
  public void setTest() {
    v1.set(v2);

    for(int i = 0; i < v1.size(); i ++) {
      assertEquals(v2.get(i), v1.get(i));
    }
    
    boolean except = false;
    try {
      v1.set(0.6, smallSize);
    } catch (IndexOutOfBoundsException e) {
      except = true;
    }
    
    assertTrue(except);
  }
  
  public void subVector() {
    int start = 2;
    Vector subVector = v1.subVector(start, v1.size() - 1);
    Iterator<Writable> it = subVector.iterator();

    int i = start;
    while (it.hasNext()) {
      assertEquals(v1.get(i), ((DoubleEntry) it.next()).getValue());
      i++;
    }
  }
  
  /**
   * Clear test
   */
  public void clear() {
    ((DenseVector) v1).clear();
    assertEquals(v1.size(), 0);
  }
}
src/test/org/apache/hama/matrix/TestDenseVector.java
v2.scale(0.5);

    for (int i = 0; i < v2.size(); i++) {
      assertEquals(values[1][i] * 0.5, v2.get(i));
void scalingTest()
src/test/org/apache/hama/matrix/TestDenseVector.java
v1.add(v2);
    int i = 0;
    Iterator<Writable> it = v1.iterator();
    while (it.hasNext()) {
      DoubleEntry c = (DoubleEntry) it.next();
      assertEquals(c.getValue(), values[0][i] + values[1][i]);
      i++;
void add()
src/test/org/apache/hama/matrix/TestDenseVector.java
v1.set(v2);

    for(int i = 0; i < v1.size(); i ++) {
      assertEquals(v2.get(i), v1.get(i));
void setTest()
src/test/org/apache/hama/matrix/TestDenseVector.java
int start = 2;
    Vector subVector = v1.subVector(start, v1.size() - 1);
    Iterator<Writable> it = subVector.iterator();

    int i = start;
    while (it.hasNext()) {
      assertEquals(v1.get(i), ((DoubleEntry) it.next()).getValue());
      i++;
void subVector()
src/test/org/apache/hama/matrix/TestDenseVector.java
((DenseVector) v1).clear();
    assertEquals(v1.size(), 0);
void clear()
/**
 * Copyright 2007 The Apache Software Foundation
 *
 * 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.hama.matrix;

import java.io.IOException;
import java.util.Iterator;

import junit.extensions.TestSetup;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.io.Writable;
import org.apache.hama.io.DoubleEntry;
import org.apache.hama.matrix.DenseMatrix;
import org.apache.hama.matrix.DenseVector;
import org.apache.hama.matrix.Vector;

public class TestDenseVector extends TestCase {
  final static Log LOG = LogFactory.getLog(TestDenseVector.class.getName());
  
  private static final double cosine = 0.6978227007909176;
  private static final double norm1 = 12.0;
  private static final double norm2 = 6.782329983125268;
  private static final double normInf = 5.0;
  private static final double norm2Robust = 6.782329983125269;
  private static double[][] values = { { 2, 5, 1, 4 }, { 4, 1, 3, 3 } };
  private static DenseMatrix m1;
  private static DenseVector v1;
  private static DenseVector v2;
  private static DenseVector smallSize = new DenseVector();
  
  public static Test suite() {
    TestSetup setup = new TestSetup(new TestSuite(TestDenseVector.class)) {
      protected void setUp() throws Exception {
        HCluster hCluster = new HCluster();
        hCluster.setUp();

        m1 = new DenseMatrix(hCluster.getConf(), 2, 4);

        for (int i = 0; i < 2; i++)
          for (int j = 0; j < 4; j++)
            m1.set(i, j, values[i][j]);

        v1 = m1.getRow(0);
        v2 = m1.getRow(1);
        smallSize.set(0, 0.5);
      }

      protected void tearDown() {
        LOG.info("tearDown()");
      }
    };
    return setup;
  }

  /**
   * Test |a| dot |b|
   */
  public void testDot() {
    double cos = v1.dot(v2);
    assertEquals(cos, cosine);
    
    boolean except = false;
    try {
      v1.dot(smallSize);
    } catch (IndexOutOfBoundsException e) {
      except = true;
    }
    
    assertTrue(except);
  }

  public void testSubVector() {
    int start = 2;
    Vector subVector = v1.subVector(start, v1.size() - 1);
    Iterator<Writable> it = subVector.iterator();

    int i = start;
    while (it.hasNext()) {
      assertEquals(v1.get(i), ((DoubleEntry) it.next()).getValue());
      i++;
    }
  }

  /**
   * Test norm one
   */
  public void testNom1() {
    assertEquals(norm1, v1.norm(Vector.Norm.One));
  }

  /**
   * Test norm two
   */
  public void testNom2() {
    assertEquals(norm2, v1.norm(Vector.Norm.Two));
  }

  /**
   * Test infinity norm
   */
  public void testNormInf() {
    assertEquals(normInf, v1.norm(Vector.Norm.Infinity));
  }
  
  /**
   * Test infinity norm
   */
  public void testNorm2Robust() {
    assertEquals(norm2Robust, v1.norm(Vector.Norm.TwoRobust));
  }
  
  /**
   * Test scaling
   */
  public void scalingTest() {
    v2.scale(0.5);

    for (int i = 0; i < v2.size(); i++) {
      assertEquals(values[1][i] * 0.5, v2.get(i));
    }
  }

  /**
   * Test get/set methods
   * @throws IOException 
   */
  public void testGetSet() throws IOException {
    assertEquals(v1.get(0), values[0][0]);
    boolean ex = false;
    try {
      v1.get(5);
    } catch (NullPointerException e) {
      ex = true;
    }
    assertTrue(ex);
    assertEquals(m1.getColumn(0).size(), 2);
  }

  /**
   * Test add()
   */
  public void testAdd() {
    v1.add(v2);
    int i = 0;
    Iterator<Writable> it = v1.iterator();
    while (it.hasNext()) {
      DoubleEntry c = (DoubleEntry) it.next();
      assertEquals(c.getValue(), values[0][i] + values[1][i]);
      i++;
    }

    v1.add(0.5, v2);
    int j = 0;
    Iterator<Writable> itt = v1.iterator();
    while (itt.hasNext()) {
      DoubleEntry c = (DoubleEntry) itt.next();
      assertEquals(c.getValue(), (values[0][j] + values[1][j]) + (0.5 * values[1][j]));
      j++;
    }
    
    double old = v1.get(0);
    v1.add(0, norm1);
    assertEquals(v1.get(0), old + norm1);
    
    boolean except = false;
    try {
      v1.add(smallSize);
    } catch (IndexOutOfBoundsException e) {
      except = true;
    }
    
    assertTrue(except);
    
    except = false;
    try {
      v1.add(0.6, smallSize);
    } catch (IndexOutOfBoundsException e) {
      except = true;
    }
    
    assertTrue(except);
  }
  
  public void testSet() {
    v1.set(v2);
    
    for(int i = 0; i < v1.size(); i ++) {
      assertEquals(v2.get(i), v1.get(i));
    }
    
    boolean except = false;
    try {
      v1.set(0.6, smallSize);
    } catch (IndexOutOfBoundsException e) {
      except = true;
    }
    
    assertTrue(except);
  }
  
  /**
   * Clear test
   */
  public void testClear() {
    ((DenseVector) v1).clear();
    assertEquals(v1.size(), 0);
  }
}

src/test/org/apache/hama/matrix/TestDenseVector.java
TestSetup setup = new TestSetup(new TestSuite(TestDenseVector.class)) {
      protected void setUp() throws Exception {
        HCluster hCluster = new HCluster();
        hCluster.setUp();

        m1 = new DenseMatrix(hCluster.getConf(), 2, 4);

        for (int i = 0; i < 2; i++)
          for (int j = 0; j < 4; j++)
            m1.set(i, j, values[i][j]);

        v1 = m1.getRow(0);
        v2 = m1.getRow(1);
        smallSize.set(0, 0.5);
Test suite()
src/test/org/apache/hama/matrix/TestDenseVector.java
LOG.info("tearDown()");
void tearDown()
src/test/org/apache/hama/matrix/TestDenseVector.java
double cos = v1.dot(v2);
    assertEquals(cos, cosine);
    
    boolean except = false;
    try {
      v1.dot(smallSize);
void testDot()
src/test/org/apache/hama/matrix/TestDenseVector.java
int start = 2;
    Vector subVector = v1.subVector(start, v1.size() - 1);
    Iterator<Writable> it = subVector.iterator();

    int i = start;
    while (it.hasNext()) {
      assertEquals(v1.get(i), ((DoubleEntry) it.next()).getValue());
      i++;
void testSubVector()
src/test/org/apache/hama/matrix/TestDenseVector.java
assertEquals(norm1, v1.norm(Vector.Norm.One));
void testNom1()
src/test/org/apache/hama/matrix/TestDenseVector.java
assertEquals(norm2, v1.norm(Vector.Norm.Two));
void testNom2()
src/test/org/apache/hama/matrix/TestDenseVector.java
assertEquals(normInf, v1.norm(Vector.Norm.Infinity));
void testNormInf()
src/test/org/apache/hama/matrix/TestDenseVector.java
assertEquals(norm2Robust, v1.norm(Vector.Norm.TwoRobust));
void testNorm2Robust()
src/test/org/apache/hama/matrix/TestDenseVector.java
v2.scale(0.5);

    for (int i = 0; i < v2.size(); i++) {
      assertEquals(values[1][i] * 0.5, v2.get(i));
void scalingTest()
src/test/org/apache/hama/matrix/TestDenseVector.java
v1.add(v2);
    int i = 0;
    Iterator<Writable> it = v1.iterator();
    while (it.hasNext()) {
      DoubleEntry c = (DoubleEntry) it.next();
      assertEquals(c.getValue(), values[0][i] + values[1][i]);
      i++;
void testAdd()
src/test/org/apache/hama/matrix/TestDenseVector.java
v1.set(v2);
    
    for(int i = 0; i < v1.size(); i ++) {
      assertEquals(v2.get(i), v1.get(i));
void testSet()
src/test/org/apache/hama/matrix/TestDenseVector.java
((DenseVector) v1).clear();
    assertEquals(v1.size(), 0);
void testClear()
@@ -1,229 +1,204 @@
-/**
- * Copyright 2007 The Apache Software Foundation
- *
- * 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.hama.matrix;
-
-import java.io.IOException;
-import java.util.Iterator;
-
-import junit.extensions.TestSetup;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.hadoop.io.Writable;
-import org.apache.hama.io.DoubleEntry;
-import org.apache.hama.matrix.DenseMatrix;
-import org.apache.hama.matrix.DenseVector;
-import org.apache.hama.matrix.Vector;
-
-public class TestDenseVector extends TestCase {
-  final static Log LOG = LogFactory.getLog(TestDenseVector.class.getName());
-  
-  private static final double cosine = 0.6978227007909176;
-  private static final double norm1 = 12.0;
-  private static final double norm2 = 6.782329983125268;
-  private static final double normInf = 5.0;
-  private static final double norm2Robust = 6.782329983125269;
-  private static double[][] values = { { 2, 5, 1, 4 }, { 4, 1, 3, 3 } };
-  private static DenseMatrix m1;
-  private static DenseVector v1;
-  private static DenseVector v2;
-  private static DenseVector smallSize = new DenseVector();
-  
-  public static Test suite() {
-    TestSetup setup = new TestSetup(new TestSuite(TestDenseVector.class)) {
-      protected void setUp() throws Exception {
-        HCluster hCluster = new HCluster();
-        hCluster.setUp();
-
-        m1 = new DenseMatrix(hCluster.getConf(), 2, 4);
-
-        for (int i = 0; i < 2; i++)
-          for (int j = 0; j < 4; j++)
-            m1.set(i, j, values[i][j]);
-
-        v1 = m1.getRow(0);
-        v2 = m1.getRow(1);
-        smallSize.set(0, 0.5);
-      }
-
-      protected void tearDown() {
-        LOG.info("tearDown()");
-      }
-    };
-    return setup;
-  }
-
-  /**
-   * Test |a| dot |b|
-   */
-  public void testDot() {
-    double cos = v1.dot(v2);
-    assertEquals(cos, cosine);
-    
-    boolean except = false;
-    try {
-      v1.dot(smallSize);
-    } catch (IndexOutOfBoundsException e) {
-      except = true;
-    }
-    
-    assertTrue(except);
-  }
-
-  public void testSubVector() {
-    int start = 2;
-    Vector subVector = v1.subVector(start, v1.size() - 1);
-    Iterator<Writable> it = subVector.iterator();
-
-    int i = start;
-    while (it.hasNext()) {
-      assertEquals(v1.get(i), ((DoubleEntry) it.next()).getValue());
-      i++;
-    }
-  }
-
-  /**
-   * Test norm one
-   */
-  public void testNom1() {
-    assertEquals(norm1, v1.norm(Vector.Norm.One));
-  }
-
-  /**
-   * Test norm two
-   */
-  public void testNom2() {
-    assertEquals(norm2, v1.norm(Vector.Norm.Two));
-  }
-
-  /**
-   * Test infinity norm
-   */
-  public void testNormInf() {
-    assertEquals(normInf, v1.norm(Vector.Norm.Infinity));
-  }
-  
-  /**
-   * Test infinity norm
-   */
-  public void testNorm2Robust() {
-    assertEquals(norm2Robust, v1.norm(Vector.Norm.TwoRobust));
-  }
-  
-  /**
-   * Test scaling
-   */
-  public void scalingTest() {
-    v2.scale(0.5);
-
-    for (int i = 0; i < v2.size(); i++) {
-      assertEquals(values[1][i] * 0.5, v2.get(i));
-    }
-  }
-
-  /**
-   * Test get/set methods
-   * @throws IOException 
-   */
-  public void testGetSet() throws IOException {
-    assertEquals(v1.get(0), values[0][0]);
-    boolean ex = false;
-    try {
-      v1.get(5);
-    } catch (NullPointerException e) {
-      ex = true;
-    }
-    assertTrue(ex);
-    assertEquals(m1.getColumn(0).size(), 2);
-  }
-
-  /**
-   * Test add()
-   */
-  public void testAdd() {
-    v1.add(v2);
-    int i = 0;
-    Iterator<Writable> it = v1.iterator();
-    while (it.hasNext()) {
-      DoubleEntry c = (DoubleEntry) it.next();
-      assertEquals(c.getValue(), values[0][i] + values[1][i]);
-      i++;
-    }
-
-    v1.add(0.5, v2);
-    int j = 0;
-    Iterator<Writable> itt = v1.iterator();
-    while (itt.hasNext()) {
-      DoubleEntry c = (DoubleEntry) itt.next();
-      assertEquals(c.getValue(), (values[0][j] + values[1][j]) + (0.5 * values[1][j]));
-      j++;
-    }
-    
-    double old = v1.get(0);
-    v1.add(0, norm1);
-    assertEquals(v1.get(0), old + norm1);
-    
-    boolean except = false;
-    try {
-      v1.add(smallSize);
-    } catch (IndexOutOfBoundsException e) {
-      except = true;
-    }
-    
-    assertTrue(except);
-    
-    except = false;
-    try {
-      v1.add(0.6, smallSize);
-    } catch (IndexOutOfBoundsException e) {
-      except = true;
-    }
-    
-    assertTrue(except);
-  }
-  
-  public void testSet() {
-    v1.set(v2);
-    
-    for(int i = 0; i < v1.size(); i ++) {
-      assertEquals(v2.get(i), v1.get(i));
-    }
-    
-    boolean except = false;
-    try {
-      v1.set(0.6, smallSize);
-    } catch (IndexOutOfBoundsException e) {
-      except = true;
-    }
-    
-    assertTrue(except);
-  }
-  
-  /**
-   * Clear test
-   */
-  public void testClear() {
-    ((DenseVector) v1).clear();
-    assertEquals(v1.size(), 0);
-  }
-}
+/**
+ * Copyright 2007 The Apache Software Foundation
+ *
+ * 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.hama.matrix;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.util.Iterator;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.io.Writable;
+import org.apache.hama.HamaCluster;
+import org.apache.hama.io.DoubleEntry;
+
+public class TestDenseVector extends HamaCluster {
+  final static Log LOG = LogFactory.getLog(TestDenseVector.class.getName());
+
+  private final double cosine = 0.6978227007909176;
+  private final double norm1 = 12.0;
+  private final double norm2 = 6.782329983125268;
+  private final double normInf = 5.0;
+  private final double norm2Robust = 6.782329983125269;
+  private double[][] values = { { 2, 5, 1, 4 }, { 4, 1, 3, 3 } };
+  private DenseMatrix m1;
+  private DenseVector v1;
+  private DenseVector v2;
+  private DenseVector smallSize = new DenseVector();
+
+  /**
+   * @throws UnsupportedEncodingException
+   */
+  public TestDenseVector() throws UnsupportedEncodingException {
+    super();
+  }
+
+  public void setUp() throws Exception {
+    super.setUp();
+
+    m1 = new DenseMatrix(getConf(), 2, 4);
+
+    for (int i = 0; i < 2; i++)
+      for (int j = 0; j < 4; j++)
+        m1.set(i, j, values[i][j]);
+
+    v1 = m1.getRow(0);
+    v2 = m1.getRow(1);
+    smallSize.set(0, 0.5);
+  }
+
+  /**
+   * @throws IOException 
+   */
+  public void testDenseVector() throws IOException {
+    double cos = v1.dot(v2);
+    assertEquals(cos, cosine);
+
+    boolean except = false;
+    try {
+      v1.dot(smallSize);
+    } catch (IndexOutOfBoundsException e) {
+      except = true;
+    }
+    
+    assertTrue(except);
+    subVector();
+        
+    assertEquals(norm1, v1.norm(Vector.Norm.One));
+    assertEquals(norm2, v1.norm(Vector.Norm.Two));
+    assertEquals(normInf, v1.norm(Vector.Norm.Infinity));
+    assertEquals(norm2Robust, v1.norm(Vector.Norm.TwoRobust));
+
+    getSetTest();
+    add();
+    scalingTest();
+    setTest();
+    clear();
+  }
+
+  /**
+   * Test scaling
+   */
+  public void scalingTest() {
+    v2.scale(0.5);
+
+    for (int i = 0; i < v2.size(); i++) {
+      assertEquals(values[1][i] * 0.5, v2.get(i));
+    }
+  }
+
+  /**
+   * Test get/set methods
+   * @throws IOException 
+   */
+  public void getSetTest() throws IOException {
+    assertEquals(v1.get(0), values[0][0]);
+    boolean ex = false;
+    try {
+      v1.get(5);
+    } catch (NullPointerException e) {
+      ex = true;
+    }
+    assertTrue(ex);
+    assertEquals(m1.getColumn(0).size(), 2);
+  }
+
+  /**
+   * Test add()
+   */
+  public void add() {
+    v1.add(v2);
+    int i = 0;
+    Iterator<Writable> it = v1.iterator();
+    while (it.hasNext()) {
+      DoubleEntry c = (DoubleEntry) it.next();
+      assertEquals(c.getValue(), values[0][i] + values[1][i]);
+      i++;
+    }
+
+    v1.add(0.5, v2);
+    int j = 0;
+    Iterator<Writable> itt = v1.iterator();
+    while (itt.hasNext()) {
+      DoubleEntry c = (DoubleEntry) itt.next();
+      assertEquals(c.getValue(), (values[0][j] + values[1][j]) + (0.5 * values[1][j]));
+      j++;
+    }
+    
+    double old = v1.get(0);
+    v1.add(0, norm1);
+    assertEquals(v1.get(0), old + norm1);
+    
+    boolean except = false;
+    try {
+      v1.add(smallSize);
+    } catch (IndexOutOfBoundsException e) {
+      except = true;
+    }
+    
+    assertTrue(except);
+    
+    except = false;
+    try {
+      v1.add(0.6, smallSize);
+    } catch (IndexOutOfBoundsException e) {
+      except = true;
+    }
+    
+    assertTrue(except);
+  }
+  
+  public void setTest() {
+    v1.set(v2);
+
+    for(int i = 0; i < v1.size(); i ++) {
+      assertEquals(v2.get(i), v1.get(i));
+    }
+    
+    boolean except = false;
+    try {
+      v1.set(0.6, smallSize);
+    } catch (IndexOutOfBoundsException e) {
+      except = true;
+    }
+    
+    assertTrue(except);
+  }
+  
+  public void subVector() {
+    int start = 2;
+    Vector subVector = v1.subVector(start, v1.size() - 1);
+    Iterator<Writable> it = subVector.iterator();
+
+    int i = start;
+    while (it.hasNext()) {
+      assertEquals(v1.get(i), ((DoubleEntry) it.next()).getValue());
+      i++;
+    }
+  }
+  
+  /**
+   * Clear test
+   */
+  public void clear() {
+    ((DenseVector) v1).clear();
+    assertEquals(v1.size(), 0);
+  }
+}
https://github.com/apache/hama/raw/42584cd5328fc55a499d318dda6fefff6459242c/src%2Ftest%2Forg%2Fapache%2Fhama%2Fmatrix%2FTestDenseVector.java
5abfb33047adfd7dbd1a8699cd5e5f261bf37fea
modified
https://github.com/apache/hama/blob/42584cd5328fc55a499d318dda6fefff6459242c/src%2Ftest%2Forg%2Fapache%2Fhama%2Fmatrix%2FTestMatrixVectorMult.java
https://api.github.com/repos/apache/hama/contents/src%2Ftest%2Forg%2Fapache%2Fhama%2Fmatrix%2FTestMatrixVectorMult.java?ref=42584cd5328fc55a499d318dda6fefff6459242c
src/test/org/apache/hama/matrix/TestMatrixVectorMult.java
import java.io.UnsupportedEncodingException;
import org.apache.hama.HamaCluster;
public class TestMatrixVectorMult extends HamaCluster {
  private Matrix m1, m2;
  private HamaConfiguration conf;
  private double[][] result = { { 5 }, { 11 } };
  /**
   * @throws UnsupportedEncodingException
   */
  public TestMatrixVectorMult() throws UnsupportedEncodingException {
    super();
  }
  public void setUp() throws Exception {
    super.setUp();
    conf = getConf();
    m1 = new DenseMatrix(conf, "A", true);
    m1.setDimension(2, 2);
    m1.set(0, 0, 1);
    m1.set(0, 1, 2);
    m1.set(1, 0, 3);
    m1.set(1, 1, 4);
    m2 = new DenseMatrix(conf, "B", true);
    m2.setDimension(2, 1);
    m2.set(0, 0, 1);
    m2.set(1, 0, 2);
import junit.extensions.TestSetup;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

public class TestMatrixVectorMult extends TestCase {
  private static Matrix m1;
  private static Matrix m2;
  private static HamaConfiguration conf;
  private static double[][] result = { { 5 }, { 11 } };

  public static Test suite() {
    TestSetup setup = new TestSetup(new TestSuite(TestMatrixVectorMult.class)) {
      protected void setUp() throws Exception {
        HCluster hCluster = new HCluster();
        hCluster.setUp();
        conf = hCluster.getConf();
        m1 = new DenseMatrix(conf, "A", true);
        m1.setDimension(2, 2);
        m1.set(0, 0, 1);
        m1.set(0, 1, 2);
        m1.set(1, 0, 3);
        m1.set(1, 1, 4);
        m2 = new DenseMatrix(conf, "B", true);
        m2.setDimension(2, 1);
        m2.set(0, 0, 1);
        m2.set(1, 0, 2);
      }
      protected void tearDown() {
        try {
          closeTest();
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
    };
    return setup;
  }
  public static void closeTest() throws IOException {
    m1.close();
    m2.close();
src/test/org/apache/hama/matrix/TestMatrixVectorMult.java
TestSetup setup = new TestSetup(new TestSuite(TestMatrixVectorMult.class)) {
      protected void setUp() throws Exception {
        HCluster hCluster = new HCluster();
        hCluster.setUp();
        conf = hCluster.getConf();
        m1 = new DenseMatrix(conf, "A", true);
        m1.setDimension(2, 2);
        m1.set(0, 0, 1);
        m1.set(0, 1, 2);
        m1.set(1, 0, 3);
        m1.set(1, 1, 4);
        m2 = new DenseMatrix(conf, "B", true);
        m2.setDimension(2, 1);
        m2.set(0, 0, 1);
        m2.set(1, 0, 2);
Test suite()
src/test/org/apache/hama/matrix/TestMatrixVectorMult.java
try {
          closeTest();
void tearDown()
@@ -20,56 +20,40 @@
 package org.apache.hama.matrix;
 
 import java.io.IOException;
+import java.io.UnsupportedEncodingException;
 
-import junit.extensions.TestSetup;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
+import org.apache.hama.HamaCluster;
 import org.apache.hama.HamaConfiguration;
 import org.apache.log4j.Logger;
 
-public class TestMatrixVectorMult extends TestCase {
+public class TestMatrixVectorMult extends HamaCluster {
   static final Logger LOG = Logger.getLogger(TestMatrixVectorMult.class);
-  private static Matrix m1;
-  private static Matrix m2;
-  private static HamaConfiguration conf;
-  private static double[][] result = { { 5 }, { 11 } };
-
-  public static Test suite() {
-    TestSetup setup = new TestSetup(new TestSuite(TestMatrixVectorMult.class)) {
-      protected void setUp() throws Exception {
-        HCluster hCluster = new HCluster();
-        hCluster.setUp();
+  private Matrix m1, m2;
+  private HamaConfiguration conf;
+  private double[][] result = { { 5 }, { 11 } };
 
-        conf = hCluster.getConf();
+  /**
+   * @throws UnsupportedEncodingException
+   */
+  public TestMatrixVectorMult() throws UnsupportedEncodingException {
+    super();
+  }
 
-        m1 = new DenseMatrix(conf, "A", true);
-        m1.setDimension(2, 2);
-        m1.set(0, 0, 1);
-        m1.set(0, 1, 2);
-        m1.set(1, 0, 3);
-        m1.set(1, 1, 4);
-        m2 = new DenseMatrix(conf, "B", true);
-        m2.setDimension(2, 1);
-        m2.set(0, 0, 1);
-        m2.set(1, 0, 2);
-      }
+  public void setUp() throws Exception {
+    super.setUp();
 
-      protected void tearDown() {
-        try {
-          closeTest();
-        } catch (IOException e) {
-          e.printStackTrace();
-        }
-      }
-    };
-    return setup;
-  }
+    conf = getConf();
 
-  public static void closeTest() throws IOException {
-    m1.close();
-    m2.close();
+    m1 = new DenseMatrix(conf, "A", true);
+    m1.setDimension(2, 2);
+    m1.set(0, 0, 1);
+    m1.set(0, 1, 2);
+    m1.set(1, 0, 3);
+    m1.set(1, 1, 4);
+    m2 = new DenseMatrix(conf, "B", true);
+    m2.setDimension(2, 1);
+    m2.set(0, 0, 1);
+    m2.set(1, 0, 2);
   }
 
   public void testMatVectorMult() throws IOException {
https://github.com/apache/hama/raw/42584cd5328fc55a499d318dda6fefff6459242c/src%2Ftest%2Forg%2Fapache%2Fhama%2Fmatrix%2FTestMatrixVectorMult.java
e547dfc18dd947678d685721bd988a41037d017f
modified
https://github.com/apache/hama/blob/42584cd5328fc55a499d318dda6fefff6459242c/src%2Ftest%2Forg%2Fapache%2Fhama%2Fmatrix%2FTestSingularValueDecomposition.java
https://api.github.com/repos/apache/hama/contents/src%2Ftest%2Forg%2Fapache%2Fhama%2Fmatrix%2FTestSingularValueDecomposition.java?ref=42584cd5328fc55a499d318dda6fefff6459242c
src/test/org/apache/hama/matrix/TestSingularValueDecomposition.java
import java.io.UnsupportedEncodingException;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hama.HamaCluster;
public class TestSingularValueDecomposition extends HamaCluster {
  static final Logger LOG = Logger
      .getLogger(TestSingularValueDecomposition.class);
  private DenseMatrix m1;
  private HamaConfiguration conf;
  /**
   * @throws UnsupportedEncodingException
   */
  public TestSingularValueDecomposition() throws UnsupportedEncodingException {
    super();
  }
  public void setUp() throws Exception {
    super.setUp();
    conf = getConf();
    m1 = new DenseMatrix(conf, 2, 2);
    for (int i = 0; i < 2; i++)
      for (int j = 0; j < 2; j++)
        m1.set(i, j, matrixA[i][j]);
  // Let's assume the A = [4 0; 3-5]
  private double[][] matrixA = { { 4, 0 }, { 3, -5 } };
  // A'A = [25 -15; -15 25]
  private double[][] values = { { 25, -15 }, { -15, 25 } };
  // Then, eigenvalues of A'A are 10, 40
  private double[] eigenvalues = { 10, 40 };
  // And, Singular values are 3.1623, 6.3246
  private double[] singularvalues = { 3.1622776601683795, 6.324555320336759 };


    for (int i = 0; i < m1.getRows(); i++) {
      for (int j = 0; j < m1.getRows(); j++) {

    for (int x = 0; x < 2; x++) {
      Get get = new Get(BytesUtil.getRowIndex(x));
      get.addColumn(Bytes.toBytes(JacobiEigenValue.EIVAL));
      double eigenvalue = BytesUtil.bytesToDouble(table.get(get).getCellValue()
          .getValue());

    // TODO: need to compute the inverse of S, S(-1)
    // TODO: need to find out the V(T)

import junit.extensions.TestSetup;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

public class TestSingularValueDecomposition extends TestCase {
  static final Logger LOG = Logger.getLogger(TestSingularValueDecomposition.class);
  private static DenseMatrix m1;
  private static HamaConfiguration conf;
  // Let's assume the A = [4 0; 3-5]
  private static double[][] matrixA = {{4, 0}, {3, -5}};
  // A'A = [25 -15; -15 25]
  private static double[][] values = { { 25, -15 }, { -15, 25 } };
  // Then, eigenvalues of A'A are 10, 40 
  private static double[] eigenvalues = { 10, 40};
  // And, Singular values are 3.1623, 6.3246
  private static double[] singularvalues = { 3.1622776601683795, 6.324555320336759 };
  
  public static Test suite() {
    TestSetup setup = new TestSetup(new TestSuite(TestSingularValueDecomposition.class)) {
      protected void setUp() throws Exception {
        HCluster hCluster = new HCluster();
        hCluster.setUp();
        conf = hCluster.getConf();
        m1 = new DenseMatrix(conf, 2, 2);
        for (int i = 0; i < 2; i++)
          for (int j = 0; j < 2; j++)
            m1.set(i, j, matrixA[i][j]);
      }
      protected void tearDown() {
        // do nothing
      }
    };
    return setup;
    
    for(int i = 0; i < m1.getRows(); i++) {
      for(int j = 0; j < m1.getRows(); j++) {
    
    for(int x=0; x<2; x++) {
      double eigenvalue = BytesUtil.bytesToDouble(table.get(BytesUtil.getRowIndex(x), 
          Bytes.toBytes(JacobiEigenValue.EIVAL)).getValue());
    
    //TODO: need to compute the inverse of S, S(-1)
    //TODO: need to find out the V(T)
    
src/test/org/apache/hama/matrix/TestSingularValueDecomposition.java
TestSetup setup = new TestSetup(new TestSuite(TestSingularValueDecomposition.class)) {
      protected void setUp() throws Exception {
        HCluster hCluster = new HCluster();
        hCluster.setUp();
        conf = hCluster.getConf();
        m1 = new DenseMatrix(conf, 2, 2);
        for (int i = 0; i < 2; i++)
          for (int j = 0; j < 2; j++)
            m1.set(i, j, matrixA[i][j]);
Test suite()
src/test/org/apache/hama/matrix/TestSingularValueDecomposition.java
// do nothing
void tearDown()
@@ -20,77 +20,75 @@
 package org.apache.hama.matrix;
 
 import java.io.IOException;
+import java.io.UnsupportedEncodingException;
 
-import junit.extensions.TestSetup;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
+import org.apache.hadoop.hbase.client.Get;
 import org.apache.hadoop.hbase.client.HTable;
 import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hama.HamaCluster;
 import org.apache.hama.HamaConfiguration;
 import org.apache.hama.matrix.algebra.JacobiEigenValue;
 import org.apache.hama.util.BytesUtil;
 import org.apache.log4j.Logger;
 
-public class TestSingularValueDecomposition extends TestCase {
-  static final Logger LOG = Logger.getLogger(TestSingularValueDecomposition.class);
-  private static DenseMatrix m1;
-  private static HamaConfiguration conf;
+public class TestSingularValueDecomposition extends HamaCluster {
+  static final Logger LOG = Logger
+      .getLogger(TestSingularValueDecomposition.class);
+  private DenseMatrix m1;
+  private HamaConfiguration conf;
 
-  // Let's assume the A = [4 0; 3-5]
-  private static double[][] matrixA = {{4, 0}, {3, -5}};
-  // A'A = [25 -15; -15 25]
-  private static double[][] values = { { 25, -15 }, { -15, 25 } };
-  // Then, eigenvalues of A'A are 10, 40 
-  private static double[] eigenvalues = { 10, 40};
-  // And, Singular values are 3.1623, 6.3246
-  private static double[] singularvalues = { 3.1622776601683795, 6.324555320336759 };
-  
-  public static Test suite() {
-    TestSetup setup = new TestSetup(new TestSuite(TestSingularValueDecomposition.class)) {
-      protected void setUp() throws Exception {
-        HCluster hCluster = new HCluster();
-        hCluster.setUp();
+  /**
+   * @throws UnsupportedEncodingException
+   */
+  public TestSingularValueDecomposition() throws UnsupportedEncodingException {
+    super();
+  }
 
-        conf = hCluster.getConf();
-        m1 = new DenseMatrix(conf, 2, 2);
-        for (int i = 0; i < 2; i++)
-          for (int j = 0; j < 2; j++)
-            m1.set(i, j, matrixA[i][j]);
-      }
+  public void setUp() throws Exception {
+    super.setUp();
 
-      protected void tearDown() {
-        // do nothing
-      }
-    };
-    return setup;
+    conf = getConf();
+    m1 = new DenseMatrix(conf, 2, 2);
+    for (int i = 0; i < 2; i++)
+      for (int j = 0; j < 2; j++)
+        m1.set(i, j, matrixA[i][j]);
   }
 
+  // Let's assume the A = [4 0; 3-5]
+  private double[][] matrixA = { { 4, 0 }, { 3, -5 } };
+  // A'A = [25 -15; -15 25]
+  private double[][] values = { { 25, -15 }, { -15, 25 } };
+  // Then, eigenvalues of A'A are 10, 40
+  private double[] eigenvalues = { 10, 40 };
+  // And, Singular values are 3.1623, 6.3246
+  private double[] singularvalues = { 3.1622776601683795, 6.324555320336759 };
+
   public void testEigenSingularValues() throws IOException {
     Matrix aT = m1.transpose();
     DenseMatrix aTa = (DenseMatrix) aT.mult(m1);
-    
-    for(int i = 0; i < m1.getRows(); i++) {
-      for(int j = 0; j < m1.getRows(); j++) {
+
+    for (int i = 0; i < m1.getRows(); i++) {
+      for (int j = 0; j < m1.getRows(); j++) {
         assertEquals(aTa.get(i, j), values[i][j]);
       }
     }
-    
+
     // Find the eigen/singular values and vectors of A'A
     aTa.jacobiEigenValue(1);
     HTable table = aTa.getHTable();
 
-    for(int x=0; x<2; x++) {
-      double eigenvalue = BytesUtil.bytesToDouble(table.get(BytesUtil.getRowIndex(x), 
-          Bytes.toBytes(JacobiEigenValue.EIVAL)).getValue());
+    for (int x = 0; x < 2; x++) {
+      Get get = new Get(BytesUtil.getRowIndex(x));
+      get.addColumn(Bytes.toBytes(JacobiEigenValue.EIVAL));
+      double eigenvalue = BytesUtil.bytesToDouble(table.get(get).getCellValue()
+          .getValue());
       assertTrue(Math.abs(eigenvalues[x] - eigenvalue) < .0000001);
       assertTrue(Math.abs(Math.pow(eigenvalue, 0.5) - singularvalues[x]) < .0000001);
     }
-    
-    //TODO: need to compute the inverse of S, S(-1)
-    //TODO: need to find out the V(T)
-    
+
+    // TODO: need to compute the inverse of S, S(-1)
+    // TODO: need to find out the V(T)
+
     // Therefore, U= AVS'1=[-0.8944 -0.4472; 0.4472 -0.8944]
     // A = USV'=[4 0; 3 -5]
   }
https://github.com/apache/hama/raw/42584cd5328fc55a499d318dda6fefff6459242c/src%2Ftest%2Forg%2Fapache%2Fhama%2Fmatrix%2FTestSingularValueDecomposition.java
2f5732ddd544ca667283c33d3248d0e164e4b315
modified
https://github.com/apache/hama/blob/42584cd5328fc55a499d318dda6fefff6459242c/src%2Ftest%2Forg%2Fapache%2Fhama%2Fmatrix%2FTestSparseMatrix.java
https://api.github.com/repos/apache/hama/contents/src%2Ftest%2Forg%2Fapache%2Fhama%2Fmatrix%2FTestSparseMatrix.java?ref=42584cd5328fc55a499d318dda6fefff6459242c
src/test/org/apache/hama/matrix/TestSparseMatrix.java
import java.io.UnsupportedEncodingException;
import org.apache.hama.HamaCluster;
public class TestSparseMatrix extends HamaCluster {
  private int SIZE = 10;
  private SparseMatrix m1;
  private SparseMatrix m2;
  /**
   * @throws UnsupportedEncodingException
   */
  public TestSparseMatrix() throws UnsupportedEncodingException {
    super();
  public void setUp() throws Exception {
    super.setUp();
    m1 = SparseMatrix.random(getConf(), SIZE, SIZE);
    m2 = SparseMatrix.random(getConf(), SIZE, SIZE);
  public void testMult() throws IOException {
    assertTrue(m1.getRows() > 0);
    sparsity();
    
    SparseMatrix result = m1.mult(m2);
    verifyMultResult(m1, m2, result);
  
  public void sparsity() throws IOException {
import junit.extensions.TestSetup;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

import org.apache.hama.matrix.Matrix.Norm;
public class TestSparseMatrix extends TestCase {
  private static int SIZE = 10;
  private static SparseMatrix m1;
  private static SparseMatrix m2;

  public static Test suite() {
    TestSetup setup = new TestSetup(new TestSuite(TestSparseMatrix.class)) {
      protected void setUp() throws Exception {
        HCluster hCluster = new HCluster();
        hCluster.setUp();

        m1 = SparseMatrix.random(hCluster.getConf(), SIZE, SIZE);
        m2 = SparseMatrix.random(hCluster.getConf(), SIZE, SIZE);
      }
      protected void tearDown() {
        try {
          closeTest();
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
    };
    return setup;
  public static void closeTest() throws IOException {
    m1.close();
    m2.close();
  public void testTranspose() throws IOException {
    SparseMatrix trans = (SparseMatrix) m1.transpose();
    for (int i = 0; i < trans.getRows(); i++) {
      for (int j = 0; j < trans.getColumns(); j++) {
        assertEquals(trans.get(i, j), m1.get(j, i));
      }
    }

  public void testSparsity() throws IOException {
  /**
   * Test matrices multiplication
   * 
   * @throws IOException
   */
  public void testMatrixMult() throws IOException {
    SparseMatrix result = m1.mult(m2);
    verifyMultResult(m1, m2, result);
  }

  public void testNorm1() throws IOException {
    double gap = 0.000001;
    
    double norm1 = m1.norm(Norm.One);
    double verify_norm1 = MatrixTestCommon.verifyNorm1(m1);
    gap = norm1 - verify_norm1;
    LOG.info("Norm One : gap " + gap);
    assertTrue(gap < 0.000001 && gap > -0.000001);
    
    double normInfinity = m1.norm(Norm.Infinity);
    double verify_normInf = MatrixTestCommon.verifyNormInfinity(m1);
    gap = normInfinity - verify_normInf;
    LOG.info("Norm Infinity : gap " + gap);
    assertTrue(gap < 0.000001 && gap > -0.000001);
    
    double normMaxValue = m1.norm(Norm.Maxvalue);
    double verify_normMV = MatrixTestCommon.verifyNormMaxValue(m1);
    gap = normMaxValue - verify_normMV;
    LOG.info("Norm MaxValue : gap " + gap);
    assertTrue(gap < 0.000001 && gap > -0.000001);
    
    double normFrobenius = m1.norm(Norm.Frobenius);
    double verify_normFrobenius = MatrixTestCommon.verifyNormFrobenius(m1);
    gap = normFrobenius - verify_normFrobenius;
    LOG.info("Norm Frobenius : gap " + gap);
    assertTrue(gap < 0.000001 && gap > -0.000001);
  }

 
src/test/org/apache/hama/matrix/TestSparseMatrix.java
TestSetup setup = new TestSetup(new TestSuite(TestSparseMatrix.class)) {
      protected void setUp() throws Exception {
        HCluster hCluster = new HCluster();
        hCluster.setUp();

        m1 = SparseMatrix.random(hCluster.getConf(), SIZE, SIZE);
        m2 = SparseMatrix.random(hCluster.getConf(), SIZE, SIZE);
Test suite()
src/test/org/apache/hama/matrix/TestSparseMatrix.java
try {
          closeTest();
void tearDown()
@@ -20,57 +20,39 @@
 package org.apache.hama.matrix;
 
 import java.io.IOException;
+import java.io.UnsupportedEncodingException;
 
-import junit.extensions.TestSetup;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.apache.hama.matrix.Matrix.Norm;
+import org.apache.hama.HamaCluster;
 import org.apache.log4j.Logger;
 
-public class TestSparseMatrix extends TestCase {
+public class TestSparseMatrix extends HamaCluster {
   static final Logger LOG = Logger.getLogger(TestSparseMatrix.class);
-  private static int SIZE = 10;
-  private static SparseMatrix m1;
-  private static SparseMatrix m2;
-
-  public static Test suite() {
-    TestSetup setup = new TestSetup(new TestSuite(TestSparseMatrix.class)) {
-      protected void setUp() throws Exception {
-        HCluster hCluster = new HCluster();
-        hCluster.setUp();
-
-        m1 = SparseMatrix.random(hCluster.getConf(), SIZE, SIZE);
-        m2 = SparseMatrix.random(hCluster.getConf(), SIZE, SIZE);
-      }
+  private int SIZE = 10;
+  private SparseMatrix m1;
+  private SparseMatrix m2;
 
-      protected void tearDown() {
-        try {
-          closeTest();
-        } catch (IOException e) {
-          e.printStackTrace();
-        }
-      }
-    };
-    return setup;
+  /**
+   * @throws UnsupportedEncodingException
+   */
+  public TestSparseMatrix() throws UnsupportedEncodingException {
+    super();
   }
 
-  public static void closeTest() throws IOException {
-    m1.close();
-    m2.close();
+  public void setUp() throws Exception {
+    super.setUp();
+    m1 = SparseMatrix.random(getConf(), SIZE, SIZE);
+    m2 = SparseMatrix.random(getConf(), SIZE, SIZE);
   }
 
-  public void testTranspose() throws IOException {
-    SparseMatrix trans = (SparseMatrix) m1.transpose();
-    for (int i = 0; i < trans.getRows(); i++) {
-      for (int j = 0; j < trans.getColumns(); j++) {
-        assertEquals(trans.get(i, j), m1.get(j, i));
-      }
-    }
+  public void testMult() throws IOException {
+    assertTrue(m1.getRows() > 0);
+    sparsity();
+    
+    SparseMatrix result = m1.mult(m2);
+    verifyMultResult(m1, m2, result);
   }
-
-  public void testSparsity() throws IOException {
+  
+  public void sparsity() throws IOException {
     boolean appeared = false;
     for (int i = 0; i < m1.getRows(); i++) {
       for (int j = 0; j < m1.getColumns(); j++) {
@@ -82,44 +64,6 @@ public void testSparsity() throws IOException {
     assertTrue(appeared);
   }
 
-  /**
-   * Test matrices multiplication
-   * 
-   * @throws IOException
-   */
-  public void testMatrixMult() throws IOException {
-    SparseMatrix result = m1.mult(m2);
-    verifyMultResult(m1, m2, result);
-  }
-
-  public void testNorm1() throws IOException {
-    double gap = 0.000001;
-    
-    double norm1 = m1.norm(Norm.One);
-    double verify_norm1 = MatrixTestCommon.verifyNorm1(m1);
-    gap = norm1 - verify_norm1;
-    LOG.info("Norm One : gap " + gap);
-    assertTrue(gap < 0.000001 && gap > -0.000001);
-    
-    double normInfinity = m1.norm(Norm.Infinity);
-    double verify_normInf = MatrixTestCommon.verifyNormInfinity(m1);
-    gap = normInfinity - verify_normInf;
-    LOG.info("Norm Infinity : gap " + gap);
-    assertTrue(gap < 0.000001 && gap > -0.000001);
-    
-    double normMaxValue = m1.norm(Norm.Maxvalue);
-    double verify_normMV = MatrixTestCommon.verifyNormMaxValue(m1);
-    gap = normMaxValue - verify_normMV;
-    LOG.info("Norm MaxValue : gap " + gap);
-    assertTrue(gap < 0.000001 && gap > -0.000001);
-    
-    double normFrobenius = m1.norm(Norm.Frobenius);
-    double verify_normFrobenius = MatrixTestCommon.verifyNormFrobenius(m1);
-    gap = normFrobenius - verify_normFrobenius;
-    LOG.info("Norm Frobenius : gap " + gap);
-    assertTrue(gap < 0.000001 && gap > -0.000001);
-  }
-
   /**
    * Verifying multiplication result
    * 
@@ -147,5 +91,4 @@ private void verifyMultResult(SparseMatrix m1, SparseMatrix m2,
       }
     }
   }
- 
 }
https://github.com/apache/hama/raw/42584cd5328fc55a499d318dda6fefff6459242c/src%2Ftest%2Forg%2Fapache%2Fhama%2Fmatrix%2FTestSparseMatrix.java
f7d19b275967c37c12bdf3dbeb363b9feb41406c
modified
https://github.com/apache/hama/blob/42584cd5328fc55a499d318dda6fefff6459242c/src%2Ftest%2Forg%2Fapache%2Fhama%2Fmatrix%2FTestSparseVector.java
https://api.github.com/repos/apache/hama/contents/src%2Ftest%2Forg%2Fapache%2Fhama%2Fmatrix%2FTestSparseVector.java?ref=42584cd5328fc55a499d318dda6fefff6459242c
src/test/org/apache/hama/matrix/TestSparseVector.java
import java.io.UnsupportedEncodingException;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hama.HamaCluster;
public class TestSparseVector extends HamaCluster {
  private SparseMatrix m1;
  private SparseVector v1;
  private SparseVector v2;
  private double[][] values = { { 2, 0, 0, 4 }, { 0, 0, 3, 3 } };
  /**
   * @throws UnsupportedEncodingException
   */
  public TestSparseVector() throws UnsupportedEncodingException {
    super();
  }
  public void setUp() throws Exception {
    super.setUp();
    m1 = new SparseMatrix(getConf(), 2, 4);
    for (int i = 0; i < 2; i++)
      for (int j = 0; j < 4; j++)
        m1.set(i, j, values[i][j]);
    v1 = m1.getRow(0);
    v2 = m1.getRow(1);
    Get get = new Get(BytesUtil.getRowIndex(0));
    get.addColumn(BytesUtil.getColumnIndex(1));
    Result r = table.get(get);
    assertTrue(r.getCellValue() == null);
    
    addTest();

  public void addTest() {

    for (int i = 0; i < values[0].length; i++) {
    for (int i = 0; i < values[0].length; i++) {
      assertEquals(v1.get(i), (values[0][i] + values[1][i])
          + (0.5 * values[1][i]));

import junit.extensions.TestSetup;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.apache.hadoop.hbase.io.Cell;
public class TestSparseVector extends TestCase {
  private static SparseMatrix m1;
  private static SparseVector v1;
  private static SparseVector v2;
  private static double[][] values = { { 2, 0, 0, 4 }, { 0, 0, 3, 3 } };

  public static Test suite() {
    TestSetup setup = new TestSetup(new TestSuite(TestSparseVector.class)) {
      protected void setUp() throws Exception {
        HCluster hCluster = new HCluster();
        hCluster.setUp();
        m1 = new SparseMatrix(hCluster.getConf(), 2, 4);
        for (int i = 0; i < 2; i++)
          for (int j = 0; j < 4; j++)
            m1.set(i, j, values[i][j]);
        v1 = m1.getRow(0);
        v2 = m1.getRow(1);
      }
      protected void tearDown() {
        LOG.info("tearDown()");
      }
    };
    return setup;
    Cell c = table.get(BytesUtil.getRowIndex(0), BytesUtil.getColumnIndex(1));
    assertTrue(c == null);
  
  public void testAdd() {
    
    for(int i = 0; i < values[0].length; i++) {
    for(int i = 0; i < values[0].length; i++) {
      assertEquals(v1.get(i),  (values[0][i] + values[1][i]) + (0.5 * values[1][i]));
src/test/org/apache/hama/matrix/TestSparseVector.java
TestSetup setup = new TestSetup(new TestSuite(TestSparseVector.class)) {
      protected void setUp() throws Exception {
        HCluster hCluster = new HCluster();
        hCluster.setUp();
        m1 = new SparseMatrix(hCluster.getConf(), 2, 4);
        for (int i = 0; i < 2; i++)
          for (int j = 0; j < 4; j++)
            m1.set(i, j, values[i][j]);
        v1 = m1.getRow(0);
        v2 = m1.getRow(1);
Test suite()
src/test/org/apache/hama/matrix/TestSparseVector.java
LOG.info("tearDown()");
void tearDown()
@@ -20,46 +20,40 @@
 package org.apache.hama.matrix;
 
 import java.io.IOException;
-
-import junit.extensions.TestSetup;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import java.io.UnsupportedEncodingException;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.hbase.client.Get;
 import org.apache.hadoop.hbase.client.HTable;
-import org.apache.hadoop.hbase.io.Cell;
+import org.apache.hadoop.hbase.client.Result;
+import org.apache.hama.HamaCluster;
 import org.apache.hama.util.BytesUtil;
 
-public class TestSparseVector extends TestCase {
+public class TestSparseVector extends HamaCluster {
   final static Log LOG = LogFactory.getLog(TestSparseVector.class.getName());
-  private static SparseMatrix m1;
-  private static SparseVector v1;
-  private static SparseVector v2;
-  private static double[][] values = { { 2, 0, 0, 4 }, { 0, 0, 3, 3 } };
-
-  public static Test suite() {
-    TestSetup setup = new TestSetup(new TestSuite(TestSparseVector.class)) {
-      protected void setUp() throws Exception {
-        HCluster hCluster = new HCluster();
-        hCluster.setUp();
+  private SparseMatrix m1;
+  private SparseVector v1;
+  private SparseVector v2;
+  private double[][] values = { { 2, 0, 0, 4 }, { 0, 0, 3, 3 } };
 
-        m1 = new SparseMatrix(hCluster.getConf(), 2, 4);
+  /**
+   * @throws UnsupportedEncodingException
+   */
+  public TestSparseVector() throws UnsupportedEncodingException {
+    super();
+  }
 
-        for (int i = 0; i < 2; i++)
-          for (int j = 0; j < 4; j++)
-            m1.set(i, j, values[i][j]);
+  public void setUp() throws Exception {
+    super.setUp();
+    m1 = new SparseMatrix(getConf(), 2, 4);
 
-        v1 = m1.getRow(0);
-        v2 = m1.getRow(1);
-      }
+    for (int i = 0; i < 2; i++)
+      for (int j = 0; j < 4; j++)
+        m1.set(i, j, values[i][j]);
 
-      protected void tearDown() {
-        LOG.info("tearDown()");
-      }
-    };
-    return setup;
+    v1 = m1.getRow(0);
+    v2 = m1.getRow(1);
   }
 
   /**
@@ -72,23 +66,28 @@ public void testGetSet() throws IOException {
     assertEquals(v2.get(1), 0.0);
 
     HTable table = m1.getHTable();
-    Cell c = table.get(BytesUtil.getRowIndex(0), BytesUtil.getColumnIndex(1));
-    assertTrue(c == null);
+    Get get = new Get(BytesUtil.getRowIndex(0));
+    get.addColumn(BytesUtil.getColumnIndex(1));
+    Result r = table.get(get);
+    assertTrue(r.getCellValue() == null);
+    
+    addTest();
   }
-  
+
   /**
    * Test add()
    */
-  public void testAdd() {
+  public void addTest() {
     v1.add(v2);
-    
-    for(int i = 0; i < values[0].length; i++) {
+
+    for (int i = 0; i < values[0].length; i++) {
       assertEquals(v1.get(i), values[0][i] + values[1][i]);
     }
 
     v1.add(0.5, v2);
-    for(int i = 0; i < values[0].length; i++) {
-      assertEquals(v1.get(i),  (values[0][i] + values[1][i]) + (0.5 * values[1][i]));
+    for (int i = 0; i < values[0].length; i++) {
+      assertEquals(v1.get(i), (values[0][i] + values[1][i])
+          + (0.5 * values[1][i]));
     }
   }
 }
https://github.com/apache/hama/raw/42584cd5328fc55a499d318dda6fefff6459242c/src%2Ftest%2Forg%2Fapache%2Fhama%2Fmatrix%2FTestSparseVector.java
abb2700c8077f6addd68fae88d631138039a2e5a
modified
apache$hama
v1.add(v2);
    int i = 0;
    Iterator<Writable> it = v1.iterator();
    while (it.hasNext()) {
      DoubleEntry c = (DoubleEntry) it.next();
      assertEquals(c.getValue(), values[0][i] + values[1][i]);
      i++;
void
void add()
v1.add(v2);
    int i = 0;
    Iterator<Writable> it = v1.iterator();
    while (it.hasNext()) {
      DoubleEntry c = (DoubleEntry) it.next();
      assertEquals(c.getValue(), values[0][i] + values[1][i]);
      i++;
void
void testAdd()
apache$hama
((DenseVector) v1).clear();
    assertEquals(v1.size(), 0);
void
void clear()
((DenseVector) v1).clear();
    assertEquals(v1.size(), 0);
void
void testClear()
apache$hama
v1.set(v2);

    for(int i = 0; i < v1.size(); i ++) {
      assertEquals(v2.get(i), v1.get(i));
void
void setTest()
v1.set(v2);
    
    for(int i = 0; i < v1.size(); i ++) {
      assertEquals(v2.get(i), v1.get(i));
void
void testSet()
apache$hama
int start = 2;
    Vector subVector = v1.subVector(start, v1.size() - 1);
    Iterator<Writable> it = subVector.iterator();

    int i = start;
    while (it.hasNext()) {
      assertEquals(v1.get(i), ((DoubleEntry) it.next()).getValue());
      i++;
void
void subVector()
int start = 2;
    Vector subVector = v1.subVector(start, v1.size() - 1);
    Iterator<Writable> it = subVector.iterator();

    int i = start;
    while (it.hasNext()) {
      assertEquals(v1.get(i), ((DoubleEntry) it.next()).getValue());
      i++;
void
void testSubVector()