You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by lu...@apache.org on 2013/04/07 01:42:02 UTC
svn commit: r857558 [14/39] - in
/websites/production/commons/content/proper/commons-math/testapidocs/src-html/org/apache/commons/math3:
./ analysis/ analysis/differentiation/ analysis/interpolation/ complex/
dfp/ distribution/ distribution/fitting/ ex...
Added: websites/production/commons/content/proper/commons-math/testapidocs/src-html/org/apache/commons/math3/linear/RRQRSolverTest.html
==============================================================================
--- websites/production/commons/content/proper/commons-math/testapidocs/src-html/org/apache/commons/math3/linear/RRQRSolverTest.html (added)
+++ websites/production/commons/content/proper/commons-math/testapidocs/src-html/org/apache/commons/math3/linear/RRQRSolverTest.html Sat Apr 6 23:42:01 2013
@@ -0,0 +1,268 @@
+<HTML>
+<BODY BGCOLOR="white">
+<PRE>
+<FONT color="green">001</FONT> /*<a name="line.1"></a>
+<FONT color="green">002</FONT> * Licensed to the Apache Software Foundation (ASF) under one or more<a name="line.2"></a>
+<FONT color="green">003</FONT> * contributor license agreements. See the NOTICE file distributed with<a name="line.3"></a>
+<FONT color="green">004</FONT> * this work for additional information regarding copyright ownership.<a name="line.4"></a>
+<FONT color="green">005</FONT> * The ASF licenses this file to You under the Apache License, Version 2.0<a name="line.5"></a>
+<FONT color="green">006</FONT> * (the "License"); you may not use this file except in compliance with<a name="line.6"></a>
+<FONT color="green">007</FONT> * the License. You may obtain a copy of the License at<a name="line.7"></a>
+<FONT color="green">008</FONT> *<a name="line.8"></a>
+<FONT color="green">009</FONT> * http://www.apache.org/licenses/LICENSE-2.0<a name="line.9"></a>
+<FONT color="green">010</FONT> *<a name="line.10"></a>
+<FONT color="green">011</FONT> * Unless required by applicable law or agreed to in writing, software<a name="line.11"></a>
+<FONT color="green">012</FONT> * distributed under the License is distributed on an "AS IS" BASIS,<a name="line.12"></a>
+<FONT color="green">013</FONT> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<a name="line.13"></a>
+<FONT color="green">014</FONT> * See the License for the specific language governing permissions and<a name="line.14"></a>
+<FONT color="green">015</FONT> * limitations under the License.<a name="line.15"></a>
+<FONT color="green">016</FONT> */<a name="line.16"></a>
+<FONT color="green">017</FONT> <a name="line.17"></a>
+<FONT color="green">018</FONT> package org.apache.commons.math3.linear;<a name="line.18"></a>
+<FONT color="green">019</FONT> <a name="line.19"></a>
+<FONT color="green">020</FONT> import java.util.Random;<a name="line.20"></a>
+<FONT color="green">021</FONT> <a name="line.21"></a>
+<FONT color="green">022</FONT> import org.apache.commons.math3.exception.MathIllegalArgumentException;<a name="line.22"></a>
+<FONT color="green">023</FONT> <a name="line.23"></a>
+<FONT color="green">024</FONT> import org.junit.Test;<a name="line.24"></a>
+<FONT color="green">025</FONT> import org.junit.Assert;<a name="line.25"></a>
+<FONT color="green">026</FONT> <a name="line.26"></a>
+<FONT color="green">027</FONT> public class RRQRSolverTest {<a name="line.27"></a>
+<FONT color="green">028</FONT> double[][] testData3x3NonSingular = {<a name="line.28"></a>
+<FONT color="green">029</FONT> { 12, -51, 4 },<a name="line.29"></a>
+<FONT color="green">030</FONT> { 6, 167, -68 },<a name="line.30"></a>
+<FONT color="green">031</FONT> { -4, 24, -41 }<a name="line.31"></a>
+<FONT color="green">032</FONT> };<a name="line.32"></a>
+<FONT color="green">033</FONT> <a name="line.33"></a>
+<FONT color="green">034</FONT> double[][] testData3x3Singular = {<a name="line.34"></a>
+<FONT color="green">035</FONT> { 1, 2, 2 },<a name="line.35"></a>
+<FONT color="green">036</FONT> { 2, 4, 6 },<a name="line.36"></a>
+<FONT color="green">037</FONT> { 4, 8, 12 }<a name="line.37"></a>
+<FONT color="green">038</FONT> };<a name="line.38"></a>
+<FONT color="green">039</FONT> <a name="line.39"></a>
+<FONT color="green">040</FONT> double[][] testData3x4 = {<a name="line.40"></a>
+<FONT color="green">041</FONT> { 12, -51, 4, 1 },<a name="line.41"></a>
+<FONT color="green">042</FONT> { 6, 167, -68, 2 },<a name="line.42"></a>
+<FONT color="green">043</FONT> { -4, 24, -41, 3 }<a name="line.43"></a>
+<FONT color="green">044</FONT> };<a name="line.44"></a>
+<FONT color="green">045</FONT> <a name="line.45"></a>
+<FONT color="green">046</FONT> double[][] testData4x3 = {<a name="line.46"></a>
+<FONT color="green">047</FONT> { 12, -51, 4 },<a name="line.47"></a>
+<FONT color="green">048</FONT> { 6, 167, -68 },<a name="line.48"></a>
+<FONT color="green">049</FONT> { -4, 24, -41 },<a name="line.49"></a>
+<FONT color="green">050</FONT> { -5, 34, 7 }<a name="line.50"></a>
+<FONT color="green">051</FONT> };<a name="line.51"></a>
+<FONT color="green">052</FONT> <a name="line.52"></a>
+<FONT color="green">053</FONT> /** test rank */<a name="line.53"></a>
+<FONT color="green">054</FONT> @Test<a name="line.54"></a>
+<FONT color="green">055</FONT> public void testRank() {<a name="line.55"></a>
+<FONT color="green">056</FONT> DecompositionSolver solver =<a name="line.56"></a>
+<FONT color="green">057</FONT> new RRQRDecomposition(MatrixUtils.createRealMatrix(testData3x3NonSingular), 1.0e-16).getSolver();<a name="line.57"></a>
+<FONT color="green">058</FONT> Assert.assertTrue(solver.isNonSingular());<a name="line.58"></a>
+<FONT color="green">059</FONT> <a name="line.59"></a>
+<FONT color="green">060</FONT> solver = new RRQRDecomposition(MatrixUtils.createRealMatrix(testData3x3Singular), 1.0e-16).getSolver();<a name="line.60"></a>
+<FONT color="green">061</FONT> Assert.assertFalse(solver.isNonSingular());<a name="line.61"></a>
+<FONT color="green">062</FONT> <a name="line.62"></a>
+<FONT color="green">063</FONT> solver = new RRQRDecomposition(MatrixUtils.createRealMatrix(testData3x4), 1.0e-16).getSolver();<a name="line.63"></a>
+<FONT color="green">064</FONT> Assert.assertTrue(solver.isNonSingular());<a name="line.64"></a>
+<FONT color="green">065</FONT> <a name="line.65"></a>
+<FONT color="green">066</FONT> solver = new RRQRDecomposition(MatrixUtils.createRealMatrix(testData4x3), 1.0e-16).getSolver();<a name="line.66"></a>
+<FONT color="green">067</FONT> Assert.assertTrue(solver.isNonSingular());<a name="line.67"></a>
+<FONT color="green">068</FONT> <a name="line.68"></a>
+<FONT color="green">069</FONT> }<a name="line.69"></a>
+<FONT color="green">070</FONT> <a name="line.70"></a>
+<FONT color="green">071</FONT> /** test solve dimension errors */<a name="line.71"></a>
+<FONT color="green">072</FONT> @Test<a name="line.72"></a>
+<FONT color="green">073</FONT> public void testSolveDimensionErrors() {<a name="line.73"></a>
+<FONT color="green">074</FONT> DecompositionSolver solver =<a name="line.74"></a>
+<FONT color="green">075</FONT> new RRQRDecomposition(MatrixUtils.createRealMatrix(testData3x3NonSingular)).getSolver();<a name="line.75"></a>
+<FONT color="green">076</FONT> RealMatrix b = MatrixUtils.createRealMatrix(new double[2][2]);<a name="line.76"></a>
+<FONT color="green">077</FONT> try {<a name="line.77"></a>
+<FONT color="green">078</FONT> solver.solve(b);<a name="line.78"></a>
+<FONT color="green">079</FONT> Assert.fail("an exception should have been thrown");<a name="line.79"></a>
+<FONT color="green">080</FONT> } catch (MathIllegalArgumentException iae) {<a name="line.80"></a>
+<FONT color="green">081</FONT> // expected behavior<a name="line.81"></a>
+<FONT color="green">082</FONT> }<a name="line.82"></a>
+<FONT color="green">083</FONT> try {<a name="line.83"></a>
+<FONT color="green">084</FONT> solver.solve(b.getColumnVector(0));<a name="line.84"></a>
+<FONT color="green">085</FONT> Assert.fail("an exception should have been thrown");<a name="line.85"></a>
+<FONT color="green">086</FONT> } catch (MathIllegalArgumentException iae) {<a name="line.86"></a>
+<FONT color="green">087</FONT> // expected behavior<a name="line.87"></a>
+<FONT color="green">088</FONT> }<a name="line.88"></a>
+<FONT color="green">089</FONT> <a name="line.89"></a>
+<FONT color="green">090</FONT> }<a name="line.90"></a>
+<FONT color="green">091</FONT> <a name="line.91"></a>
+<FONT color="green">092</FONT> /** test solve rank errors */<a name="line.92"></a>
+<FONT color="green">093</FONT> @Test<a name="line.93"></a>
+<FONT color="green">094</FONT> public void testSolveRankErrors() {<a name="line.94"></a>
+<FONT color="green">095</FONT> DecompositionSolver solver =<a name="line.95"></a>
+<FONT color="green">096</FONT> new RRQRDecomposition(MatrixUtils.createRealMatrix(testData3x3Singular), 1.0e-16).getSolver();<a name="line.96"></a>
+<FONT color="green">097</FONT> RealMatrix b = MatrixUtils.createRealMatrix(new double[3][2]);<a name="line.97"></a>
+<FONT color="green">098</FONT> try {<a name="line.98"></a>
+<FONT color="green">099</FONT> solver.solve(b);<a name="line.99"></a>
+<FONT color="green">100</FONT> Assert.fail("an exception should have been thrown");<a name="line.100"></a>
+<FONT color="green">101</FONT> } catch (SingularMatrixException iae) {<a name="line.101"></a>
+<FONT color="green">102</FONT> // expected behavior<a name="line.102"></a>
+<FONT color="green">103</FONT> }<a name="line.103"></a>
+<FONT color="green">104</FONT> try {<a name="line.104"></a>
+<FONT color="green">105</FONT> solver.solve(b.getColumnVector(0));<a name="line.105"></a>
+<FONT color="green">106</FONT> Assert.fail("an exception should have been thrown");<a name="line.106"></a>
+<FONT color="green">107</FONT> } catch (SingularMatrixException iae) {<a name="line.107"></a>
+<FONT color="green">108</FONT> // expected behavior<a name="line.108"></a>
+<FONT color="green">109</FONT> }<a name="line.109"></a>
+<FONT color="green">110</FONT> <a name="line.110"></a>
+<FONT color="green">111</FONT> }<a name="line.111"></a>
+<FONT color="green">112</FONT> <a name="line.112"></a>
+<FONT color="green">113</FONT> /** test solve */<a name="line.113"></a>
+<FONT color="green">114</FONT> @Test<a name="line.114"></a>
+<FONT color="green">115</FONT> public void testSolve() {<a name="line.115"></a>
+<FONT color="green">116</FONT> RealMatrix b = MatrixUtils.createRealMatrix(new double[][] {<a name="line.116"></a>
+<FONT color="green">117</FONT> { -102, 12250 }, { 544, 24500 }, { 167, -36750 }<a name="line.117"></a>
+<FONT color="green">118</FONT> });<a name="line.118"></a>
+<FONT color="green">119</FONT> RealMatrix xRef = MatrixUtils.createRealMatrix(new double[][] {<a name="line.119"></a>
+<FONT color="green">120</FONT> { 1, 2515 }, { 2, 422 }, { -3, 898 }<a name="line.120"></a>
+<FONT color="green">121</FONT> });<a name="line.121"></a>
+<FONT color="green">122</FONT> <a name="line.122"></a>
+<FONT color="green">123</FONT> <a name="line.123"></a>
+<FONT color="green">124</FONT> RRQRDecomposition decomposition = new RRQRDecomposition(MatrixUtils.createRealMatrix(testData3x3NonSingular));<a name="line.124"></a>
+<FONT color="green">125</FONT> DecompositionSolver solver = decomposition.getSolver();<a name="line.125"></a>
+<FONT color="green">126</FONT> <a name="line.126"></a>
+<FONT color="green">127</FONT> // using RealMatrix<a name="line.127"></a>
+<FONT color="green">128</FONT> Assert.assertEquals(0, solver.solve(b).subtract(xRef).getNorm(), 3.0e-16 * xRef.getNorm());<a name="line.128"></a>
+<FONT color="green">129</FONT> <a name="line.129"></a>
+<FONT color="green">130</FONT> // using ArrayRealVector<a name="line.130"></a>
+<FONT color="green">131</FONT> for (int i = 0; i < b.getColumnDimension(); ++i) {<a name="line.131"></a>
+<FONT color="green">132</FONT> final RealVector x = solver.solve(b.getColumnVector(i));<a name="line.132"></a>
+<FONT color="green">133</FONT> final double error = x.subtract(xRef.getColumnVector(i)).getNorm();<a name="line.133"></a>
+<FONT color="green">134</FONT> Assert.assertEquals(0, error, 3.0e-16 * xRef.getColumnVector(i).getNorm());<a name="line.134"></a>
+<FONT color="green">135</FONT> }<a name="line.135"></a>
+<FONT color="green">136</FONT> <a name="line.136"></a>
+<FONT color="green">137</FONT> // using RealVector with an alternate implementation<a name="line.137"></a>
+<FONT color="green">138</FONT> for (int i = 0; i < b.getColumnDimension(); ++i) {<a name="line.138"></a>
+<FONT color="green">139</FONT> ArrayRealVectorTest.RealVectorTestImpl v =<a name="line.139"></a>
+<FONT color="green">140</FONT> new ArrayRealVectorTest.RealVectorTestImpl(b.getColumn(i));<a name="line.140"></a>
+<FONT color="green">141</FONT> final RealVector x = solver.solve(v);<a name="line.141"></a>
+<FONT color="green">142</FONT> final double error = x.subtract(xRef.getColumnVector(i)).getNorm();<a name="line.142"></a>
+<FONT color="green">143</FONT> Assert.assertEquals(0, error, 3.0e-16 * xRef.getColumnVector(i).getNorm());<a name="line.143"></a>
+<FONT color="green">144</FONT> }<a name="line.144"></a>
+<FONT color="green">145</FONT> <a name="line.145"></a>
+<FONT color="green">146</FONT> }<a name="line.146"></a>
+<FONT color="green">147</FONT> <a name="line.147"></a>
+<FONT color="green">148</FONT> @Test<a name="line.148"></a>
+<FONT color="green">149</FONT> public void testOverdetermined() {<a name="line.149"></a>
+<FONT color="green">150</FONT> final Random r = new Random(5559252868205245l);<a name="line.150"></a>
+<FONT color="green">151</FONT> int p = (7 * BlockRealMatrix.BLOCK_SIZE) / 4;<a name="line.151"></a>
+<FONT color="green">152</FONT> int q = (5 * BlockRealMatrix.BLOCK_SIZE) / 4;<a name="line.152"></a>
+<FONT color="green">153</FONT> RealMatrix a = createTestMatrix(r, p, q);<a name="line.153"></a>
+<FONT color="green">154</FONT> RealMatrix xRef = createTestMatrix(r, q, BlockRealMatrix.BLOCK_SIZE + 3);<a name="line.154"></a>
+<FONT color="green">155</FONT> <a name="line.155"></a>
+<FONT color="green">156</FONT> // build a perturbed system: A.X + noise = B<a name="line.156"></a>
+<FONT color="green">157</FONT> RealMatrix b = a.multiply(xRef);<a name="line.157"></a>
+<FONT color="green">158</FONT> final double noise = 0.001;<a name="line.158"></a>
+<FONT color="green">159</FONT> b.walkInOptimizedOrder(new DefaultRealMatrixChangingVisitor() {<a name="line.159"></a>
+<FONT color="green">160</FONT> @Override<a name="line.160"></a>
+<FONT color="green">161</FONT> public double visit(int row, int column, double value) {<a name="line.161"></a>
+<FONT color="green">162</FONT> return value * (1.0 + noise * (2 * r.nextDouble() - 1));<a name="line.162"></a>
+<FONT color="green">163</FONT> }<a name="line.163"></a>
+<FONT color="green">164</FONT> });<a name="line.164"></a>
+<FONT color="green">165</FONT> <a name="line.165"></a>
+<FONT color="green">166</FONT> // despite perturbation, the least square solution should be pretty good<a name="line.166"></a>
+<FONT color="green">167</FONT> RealMatrix x = new RRQRDecomposition(a).getSolver().solve(b);<a name="line.167"></a>
+<FONT color="green">168</FONT> Assert.assertEquals(0, x.subtract(xRef).getNorm(), 0.01 * noise * p * q);<a name="line.168"></a>
+<FONT color="green">169</FONT> <a name="line.169"></a>
+<FONT color="green">170</FONT> }<a name="line.170"></a>
+<FONT color="green">171</FONT> <a name="line.171"></a>
+<FONT color="green">172</FONT> @Test<a name="line.172"></a>
+<FONT color="green">173</FONT> public void testUnderdetermined() {<a name="line.173"></a>
+<FONT color="green">174</FONT> final Random r = new Random(42185006424567123l);<a name="line.174"></a>
+<FONT color="green">175</FONT> int p = (5 * BlockRealMatrix.BLOCK_SIZE) / 4;<a name="line.175"></a>
+<FONT color="green">176</FONT> int q = (7 * BlockRealMatrix.BLOCK_SIZE) / 4;<a name="line.176"></a>
+<FONT color="green">177</FONT> RealMatrix a = createTestMatrix(r, p, q);<a name="line.177"></a>
+<FONT color="green">178</FONT> RealMatrix xRef = createTestMatrix(r, q, BlockRealMatrix.BLOCK_SIZE + 3);<a name="line.178"></a>
+<FONT color="green">179</FONT> RealMatrix b = a.multiply(xRef);<a name="line.179"></a>
+<FONT color="green">180</FONT> RRQRDecomposition rrqrd = new RRQRDecomposition(a);<a name="line.180"></a>
+<FONT color="green">181</FONT> RealMatrix x = rrqrd.getSolver().solve(b);<a name="line.181"></a>
+<FONT color="green">182</FONT> <a name="line.182"></a>
+<FONT color="green">183</FONT> // too many equations, the system cannot be solved at all<a name="line.183"></a>
+<FONT color="green">184</FONT> Assert.assertTrue(x.subtract(xRef).getNorm() / (p * q) > 0.01);<a name="line.184"></a>
+<FONT color="green">185</FONT> <a name="line.185"></a>
+<FONT color="green">186</FONT> // the last permuted unknown should have been set to 0<a name="line.186"></a>
+<FONT color="green">187</FONT> RealMatrix permuted = rrqrd.getP().transpose().multiply(x);<a name="line.187"></a>
+<FONT color="green">188</FONT> Assert.assertEquals(0.0, permuted.getSubMatrix(p, q - 1, 0, permuted.getColumnDimension() - 1).getNorm(), 0);<a name="line.188"></a>
+<FONT color="green">189</FONT> <a name="line.189"></a>
+<FONT color="green">190</FONT> }<a name="line.190"></a>
+<FONT color="green">191</FONT> <a name="line.191"></a>
+<FONT color="green">192</FONT> private RealMatrix createTestMatrix(final Random r, final int rows, final int columns) {<a name="line.192"></a>
+<FONT color="green">193</FONT> RealMatrix m = MatrixUtils.createRealMatrix(rows, columns);<a name="line.193"></a>
+<FONT color="green">194</FONT> m.walkInOptimizedOrder(new DefaultRealMatrixChangingVisitor() {<a name="line.194"></a>
+<FONT color="green">195</FONT> @Override<a name="line.195"></a>
+<FONT color="green">196</FONT> public double visit(int row, int column, double value) {<a name="line.196"></a>
+<FONT color="green">197</FONT> return 2.0 * r.nextDouble() - 1.0;<a name="line.197"></a>
+<FONT color="green">198</FONT> }<a name="line.198"></a>
+<FONT color="green">199</FONT> });<a name="line.199"></a>
+<FONT color="green">200</FONT> return m;<a name="line.200"></a>
+<FONT color="green">201</FONT> }<a name="line.201"></a>
+<FONT color="green">202</FONT> }<a name="line.202"></a>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+</PRE>
+</BODY>
+</HTML>
Propchange: websites/production/commons/content/proper/commons-math/testapidocs/src-html/org/apache/commons/math3/linear/RRQRSolverTest.html
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: websites/production/commons/content/proper/commons-math/testapidocs/src-html/org/apache/commons/math3/linear/RRQRSolverTest.html
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: websites/production/commons/content/proper/commons-math/testapidocs/src-html/org/apache/commons/math3/linear/SingularValueDecompositionTest.html
==============================================================================
--- websites/production/commons/content/proper/commons-math/testapidocs/src-html/org/apache/commons/math3/linear/SingularValueDecompositionTest.html (original)
+++ websites/production/commons/content/proper/commons-math/testapidocs/src-html/org/apache/commons/math3/linear/SingularValueDecompositionTest.html Sat Apr 6 23:42:01 2013
@@ -282,42 +282,56 @@
<FONT color="green">279</FONT> String strLine;<a name="line.279"></a>
<FONT color="green">280</FONT> int row = 0;<a name="line.280"></a>
<FONT color="green">281</FONT> while ((strLine = br.readLine()) != null) {<a name="line.281"></a>
-<FONT color="green">282</FONT> int col = 0;<a name="line.282"></a>
-<FONT color="green">283</FONT> for (String entry : strLine.split(",")) {<a name="line.283"></a>
-<FONT color="green">284</FONT> m.setEntry(row, col++, Double.parseDouble(entry));<a name="line.284"></a>
-<FONT color="green">285</FONT> }<a name="line.285"></a>
-<FONT color="green">286</FONT> row++;<a name="line.286"></a>
-<FONT color="green">287</FONT> }<a name="line.287"></a>
-<FONT color="green">288</FONT> in.close();<a name="line.288"></a>
-<FONT color="green">289</FONT> } catch (IOException e) {}<a name="line.289"></a>
-<FONT color="green">290</FONT> }<a name="line.290"></a>
-<FONT color="green">291</FONT> <a name="line.291"></a>
-<FONT color="green">292</FONT> /** test condition number */<a name="line.292"></a>
-<FONT color="green">293</FONT> @Test<a name="line.293"></a>
-<FONT color="green">294</FONT> public void testConditionNumber() {<a name="line.294"></a>
-<FONT color="green">295</FONT> SingularValueDecomposition svd =<a name="line.295"></a>
-<FONT color="green">296</FONT> new SingularValueDecomposition(MatrixUtils.createRealMatrix(testSquare));<a name="line.296"></a>
-<FONT color="green">297</FONT> // replace 1.0e-15 with 1.5e-15<a name="line.297"></a>
-<FONT color="green">298</FONT> Assert.assertEquals(3.0, svd.getConditionNumber(), 1.5e-15);<a name="line.298"></a>
-<FONT color="green">299</FONT> }<a name="line.299"></a>
-<FONT color="green">300</FONT> <a name="line.300"></a>
-<FONT color="green">301</FONT> @Test<a name="line.301"></a>
-<FONT color="green">302</FONT> public void testInverseConditionNumber() {<a name="line.302"></a>
-<FONT color="green">303</FONT> SingularValueDecomposition svd =<a name="line.303"></a>
-<FONT color="green">304</FONT> new SingularValueDecomposition(MatrixUtils.createRealMatrix(testSquare));<a name="line.304"></a>
-<FONT color="green">305</FONT> Assert.assertEquals(1.0/3.0, svd.getInverseConditionNumber(), 1.5e-15);<a name="line.305"></a>
-<FONT color="green">306</FONT> }<a name="line.306"></a>
-<FONT color="green">307</FONT> <a name="line.307"></a>
-<FONT color="green">308</FONT> private RealMatrix createTestMatrix(final Random r, final int rows, final int columns,<a name="line.308"></a>
-<FONT color="green">309</FONT> final double[] singularValues) {<a name="line.309"></a>
-<FONT color="green">310</FONT> final RealMatrix u = EigenDecompositionTest.createOrthogonalMatrix(r, rows);<a name="line.310"></a>
-<FONT color="green">311</FONT> final RealMatrix d = new Array2DRowRealMatrix(rows, columns);<a name="line.311"></a>
-<FONT color="green">312</FONT> d.setSubMatrix(MatrixUtils.createRealDiagonalMatrix(singularValues).getData(), 0, 0);<a name="line.312"></a>
-<FONT color="green">313</FONT> final RealMatrix v = EigenDecompositionTest.createOrthogonalMatrix(r, columns);<a name="line.313"></a>
-<FONT color="green">314</FONT> return u.multiply(d).multiply(v);<a name="line.314"></a>
-<FONT color="green">315</FONT> }<a name="line.315"></a>
-<FONT color="green">316</FONT> <a name="line.316"></a>
-<FONT color="green">317</FONT> }<a name="line.317"></a>
+<FONT color="green">282</FONT> if (!strLine.startsWith("#")) {<a name="line.282"></a>
+<FONT color="green">283</FONT> int col = 0;<a name="line.283"></a>
+<FONT color="green">284</FONT> for (String entry : strLine.split(",")) {<a name="line.284"></a>
+<FONT color="green">285</FONT> m.setEntry(row, col++, Double.parseDouble(entry));<a name="line.285"></a>
+<FONT color="green">286</FONT> }<a name="line.286"></a>
+<FONT color="green">287</FONT> row++;<a name="line.287"></a>
+<FONT color="green">288</FONT> }<a name="line.288"></a>
+<FONT color="green">289</FONT> }<a name="line.289"></a>
+<FONT color="green">290</FONT> in.close();<a name="line.290"></a>
+<FONT color="green">291</FONT> } catch (IOException e) {}<a name="line.291"></a>
+<FONT color="green">292</FONT> }<a name="line.292"></a>
+<FONT color="green">293</FONT> <a name="line.293"></a>
+<FONT color="green">294</FONT> /** test condition number */<a name="line.294"></a>
+<FONT color="green">295</FONT> @Test<a name="line.295"></a>
+<FONT color="green">296</FONT> public void testConditionNumber() {<a name="line.296"></a>
+<FONT color="green">297</FONT> SingularValueDecomposition svd =<a name="line.297"></a>
+<FONT color="green">298</FONT> new SingularValueDecomposition(MatrixUtils.createRealMatrix(testSquare));<a name="line.298"></a>
+<FONT color="green">299</FONT> // replace 1.0e-15 with 1.5e-15<a name="line.299"></a>
+<FONT color="green">300</FONT> Assert.assertEquals(3.0, svd.getConditionNumber(), 1.5e-15);<a name="line.300"></a>
+<FONT color="green">301</FONT> }<a name="line.301"></a>
+<FONT color="green">302</FONT> <a name="line.302"></a>
+<FONT color="green">303</FONT> @Test<a name="line.303"></a>
+<FONT color="green">304</FONT> public void testInverseConditionNumber() {<a name="line.304"></a>
+<FONT color="green">305</FONT> SingularValueDecomposition svd =<a name="line.305"></a>
+<FONT color="green">306</FONT> new SingularValueDecomposition(MatrixUtils.createRealMatrix(testSquare));<a name="line.306"></a>
+<FONT color="green">307</FONT> Assert.assertEquals(1.0/3.0, svd.getInverseConditionNumber(), 1.5e-15);<a name="line.307"></a>
+<FONT color="green">308</FONT> }<a name="line.308"></a>
+<FONT color="green">309</FONT> <a name="line.309"></a>
+<FONT color="green">310</FONT> private RealMatrix createTestMatrix(final Random r, final int rows, final int columns,<a name="line.310"></a>
+<FONT color="green">311</FONT> final double[] singularValues) {<a name="line.311"></a>
+<FONT color="green">312</FONT> final RealMatrix u = EigenDecompositionTest.createOrthogonalMatrix(r, rows);<a name="line.312"></a>
+<FONT color="green">313</FONT> final RealMatrix d = new Array2DRowRealMatrix(rows, columns);<a name="line.313"></a>
+<FONT color="green">314</FONT> d.setSubMatrix(MatrixUtils.createRealDiagonalMatrix(singularValues).getData(), 0, 0);<a name="line.314"></a>
+<FONT color="green">315</FONT> final RealMatrix v = EigenDecompositionTest.createOrthogonalMatrix(r, columns);<a name="line.315"></a>
+<FONT color="green">316</FONT> return u.multiply(d).multiply(v);<a name="line.316"></a>
+<FONT color="green">317</FONT> }<a name="line.317"></a>
+<FONT color="green">318</FONT> <a name="line.318"></a>
+<FONT color="green">319</FONT> @Test<a name="line.319"></a>
+<FONT color="green">320</FONT> public void testIssue947() {<a name="line.320"></a>
+<FONT color="green">321</FONT> double[][] nans = new double[][] {<a name="line.321"></a>
+<FONT color="green">322</FONT> { Double.NaN, Double.NaN },<a name="line.322"></a>
+<FONT color="green">323</FONT> { Double.NaN, Double.NaN }<a name="line.323"></a>
+<FONT color="green">324</FONT> };<a name="line.324"></a>
+<FONT color="green">325</FONT> RealMatrix m = new Array2DRowRealMatrix(nans, false);<a name="line.325"></a>
+<FONT color="green">326</FONT> SingularValueDecomposition svd = new SingularValueDecomposition(m);<a name="line.326"></a>
+<FONT color="green">327</FONT> Assert.assertTrue(Double.isNaN(svd.getSingularValues()[0]));<a name="line.327"></a>
+<FONT color="green">328</FONT> Assert.assertTrue(Double.isNaN(svd.getSingularValues()[1]));<a name="line.328"></a>
+<FONT color="green">329</FONT> }<a name="line.329"></a>
+<FONT color="green">330</FONT> <a name="line.330"></a>
+<FONT color="green">331</FONT> }<a name="line.331"></a>
Added: websites/production/commons/content/proper/commons-math/testapidocs/src-html/org/apache/commons/math3/ml/clustering/DBSCANClustererTest.html
==============================================================================
--- websites/production/commons/content/proper/commons-math/testapidocs/src-html/org/apache/commons/math3/ml/clustering/DBSCANClustererTest.html (added)
+++ websites/production/commons/content/proper/commons-math/testapidocs/src-html/org/apache/commons/math3/ml/clustering/DBSCANClustererTest.html Sat Apr 6 23:42:01 2013
@@ -0,0 +1,256 @@
+<HTML>
+<BODY BGCOLOR="white">
+<PRE>
+<FONT color="green">001</FONT> /*<a name="line.1"></a>
+<FONT color="green">002</FONT> * Licensed to the Apache Software Foundation (ASF) under one or more<a name="line.2"></a>
+<FONT color="green">003</FONT> * contributor license agreements. See the NOTICE file distributed with<a name="line.3"></a>
+<FONT color="green">004</FONT> * this work for additional information regarding copyright ownership.<a name="line.4"></a>
+<FONT color="green">005</FONT> * The ASF licenses this file to You under the Apache License, Version 2.0<a name="line.5"></a>
+<FONT color="green">006</FONT> * (the "License"); you may not use this file except in compliance with<a name="line.6"></a>
+<FONT color="green">007</FONT> * the License. You may obtain a copy of the License at<a name="line.7"></a>
+<FONT color="green">008</FONT> *<a name="line.8"></a>
+<FONT color="green">009</FONT> * http://www.apache.org/licenses/LICENSE-2.0<a name="line.9"></a>
+<FONT color="green">010</FONT> *<a name="line.10"></a>
+<FONT color="green">011</FONT> * Unless required by applicable law or agreed to in writing, software<a name="line.11"></a>
+<FONT color="green">012</FONT> * distributed under the License is distributed on an "AS IS" BASIS,<a name="line.12"></a>
+<FONT color="green">013</FONT> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<a name="line.13"></a>
+<FONT color="green">014</FONT> * See the License for the specific language governing permissions and<a name="line.14"></a>
+<FONT color="green">015</FONT> * limitations under the License.<a name="line.15"></a>
+<FONT color="green">016</FONT> */<a name="line.16"></a>
+<FONT color="green">017</FONT> package org.apache.commons.math3.ml.clustering;<a name="line.17"></a>
+<FONT color="green">018</FONT> <a name="line.18"></a>
+<FONT color="green">019</FONT> import java.util.Arrays;<a name="line.19"></a>
+<FONT color="green">020</FONT> import java.util.List;<a name="line.20"></a>
+<FONT color="green">021</FONT> <a name="line.21"></a>
+<FONT color="green">022</FONT> import org.apache.commons.math3.exception.MathIllegalArgumentException;<a name="line.22"></a>
+<FONT color="green">023</FONT> import org.apache.commons.math3.exception.NullArgumentException;<a name="line.23"></a>
+<FONT color="green">024</FONT> import org.junit.Assert;<a name="line.24"></a>
+<FONT color="green">025</FONT> import org.junit.Test;<a name="line.25"></a>
+<FONT color="green">026</FONT> <a name="line.26"></a>
+<FONT color="green">027</FONT> public class DBSCANClustererTest {<a name="line.27"></a>
+<FONT color="green">028</FONT> <a name="line.28"></a>
+<FONT color="green">029</FONT> @Test<a name="line.29"></a>
+<FONT color="green">030</FONT> public void testCluster() {<a name="line.30"></a>
+<FONT color="green">031</FONT> // Test data generated using: http://people.cs.nctu.edu.tw/~rsliang/dbscan/testdatagen.html<a name="line.31"></a>
+<FONT color="green">032</FONT> final DoublePoint[] points = new DoublePoint[] {<a name="line.32"></a>
+<FONT color="green">033</FONT> new DoublePoint(new double[] { 83.08303244924173, 58.83387754182331 }),<a name="line.33"></a>
+<FONT color="green">034</FONT> new DoublePoint(new double[] { 45.05445510940626, 23.469642649637535 }),<a name="line.34"></a>
+<FONT color="green">035</FONT> new DoublePoint(new double[] { 14.96417921432294, 69.0264096390456 }),<a name="line.35"></a>
+<FONT color="green">036</FONT> new DoublePoint(new double[] { 73.53189604333602, 34.896145021310076 }),<a name="line.36"></a>
+<FONT color="green">037</FONT> new DoublePoint(new double[] { 73.28498173551634, 33.96860806993209 }),<a name="line.37"></a>
+<FONT color="green">038</FONT> new DoublePoint(new double[] { 73.45828098873608, 33.92584423092194 }),<a name="line.38"></a>
+<FONT color="green">039</FONT> new DoublePoint(new double[] { 73.9657889183145, 35.73191006924026 }),<a name="line.39"></a>
+<FONT color="green">040</FONT> new DoublePoint(new double[] { 74.0074097183533, 36.81735596177168 }),<a name="line.40"></a>
+<FONT color="green">041</FONT> new DoublePoint(new double[] { 73.41247541410848, 34.27314856695011 }),<a name="line.41"></a>
+<FONT color="green">042</FONT> new DoublePoint(new double[] { 73.9156256353017, 36.83206791547127 }),<a name="line.42"></a>
+<FONT color="green">043</FONT> new DoublePoint(new double[] { 74.81499205809087, 37.15682749846019 }),<a name="line.43"></a>
+<FONT color="green">044</FONT> new DoublePoint(new double[] { 74.03144880081527, 37.57399178552441 }),<a name="line.44"></a>
+<FONT color="green">045</FONT> new DoublePoint(new double[] { 74.51870941207744, 38.674258946906775 }),<a name="line.45"></a>
+<FONT color="green">046</FONT> new DoublePoint(new double[] { 74.50754595105536, 35.58903978415765 }),<a name="line.46"></a>
+<FONT color="green">047</FONT> new DoublePoint(new double[] { 74.51322752749547, 36.030572259100154 }),<a name="line.47"></a>
+<FONT color="green">048</FONT> new DoublePoint(new double[] { 59.27900996617973, 46.41091720294207 }),<a name="line.48"></a>
+<FONT color="green">049</FONT> new DoublePoint(new double[] { 59.73744793841615, 46.20015558367595 }),<a name="line.49"></a>
+<FONT color="green">050</FONT> new DoublePoint(new double[] { 58.81134076672606, 45.71150126331486 }),<a name="line.50"></a>
+<FONT color="green">051</FONT> new DoublePoint(new double[] { 58.52225539437495, 47.416083617601544 }),<a name="line.51"></a>
+<FONT color="green">052</FONT> new DoublePoint(new double[] { 58.218626647023484, 47.36228902172297 }),<a name="line.52"></a>
+<FONT color="green">053</FONT> new DoublePoint(new double[] { 60.27139669447206, 46.606106348801404 }),<a name="line.53"></a>
+<FONT color="green">054</FONT> new DoublePoint(new double[] { 60.894962462363765, 46.976924697402865 }),<a name="line.54"></a>
+<FONT color="green">055</FONT> new DoublePoint(new double[] { 62.29048673878424, 47.66970563563518 }),<a name="line.55"></a>
+<FONT color="green">056</FONT> new DoublePoint(new double[] { 61.03857608977705, 46.212924720020965 }),<a name="line.56"></a>
+<FONT color="green">057</FONT> new DoublePoint(new double[] { 60.16916214139201, 45.18193661351688 }),<a name="line.57"></a>
+<FONT color="green">058</FONT> new DoublePoint(new double[] { 59.90036905976012, 47.555364347063005 }),<a name="line.58"></a>
+<FONT color="green">059</FONT> new DoublePoint(new double[] { 62.33003634144552, 47.83941489877179 }),<a name="line.59"></a>
+<FONT color="green">060</FONT> new DoublePoint(new double[] { 57.86035536718555, 47.31117930193432 }),<a name="line.60"></a>
+<FONT color="green">061</FONT> new DoublePoint(new double[] { 58.13715479685925, 48.985960494028404 }),<a name="line.61"></a>
+<FONT color="green">062</FONT> new DoublePoint(new double[] { 56.131923963548616, 46.8508904252667 }),<a name="line.62"></a>
+<FONT color="green">063</FONT> new DoublePoint(new double[] { 55.976329887053, 47.46384037658572 }),<a name="line.63"></a>
+<FONT color="green">064</FONT> new DoublePoint(new double[] { 56.23245975235477, 47.940035191131756 }),<a name="line.64"></a>
+<FONT color="green">065</FONT> new DoublePoint(new double[] { 58.51687048212625, 46.622885352699086 }),<a name="line.65"></a>
+<FONT color="green">066</FONT> new DoublePoint(new double[] { 57.85411081905477, 45.95394361577928 }),<a name="line.66"></a>
+<FONT color="green">067</FONT> new DoublePoint(new double[] { 56.445776311447844, 45.162093662656844 }),<a name="line.67"></a>
+<FONT color="green">068</FONT> new DoublePoint(new double[] { 57.36691949656233, 47.50097194337286 }),<a name="line.68"></a>
+<FONT color="green">069</FONT> new DoublePoint(new double[] { 58.243626387557015, 46.114052729681134 }),<a name="line.69"></a>
+<FONT color="green">070</FONT> new DoublePoint(new double[] { 56.27224595635198, 44.799080066150054 }),<a name="line.70"></a>
+<FONT color="green">071</FONT> new DoublePoint(new double[] { 57.606924816500396, 46.94291057763621 }),<a name="line.71"></a>
+<FONT color="green">072</FONT> new DoublePoint(new double[] { 30.18714230041951, 13.877149710431695 }),<a name="line.72"></a>
+<FONT color="green">073</FONT> new DoublePoint(new double[] { 30.449448810657486, 13.490778346545994 }),<a name="line.73"></a>
+<FONT color="green">074</FONT> new DoublePoint(new double[] { 30.295018390286714, 13.264889000216499 }),<a name="line.74"></a>
+<FONT color="green">075</FONT> new DoublePoint(new double[] { 30.160201832884923, 11.89278262341395 }),<a name="line.75"></a>
+<FONT color="green">076</FONT> new DoublePoint(new double[] { 31.341509791789576, 15.282655921997502 }),<a name="line.76"></a>
+<FONT color="green">077</FONT> new DoublePoint(new double[] { 31.68601630325429, 14.756873246748 }),<a name="line.77"></a>
+<FONT color="green">078</FONT> new DoublePoint(new double[] { 29.325963742565364, 12.097849250072613 }),<a name="line.78"></a>
+<FONT color="green">079</FONT> new DoublePoint(new double[] { 29.54820742388256, 13.613295356975868 }),<a name="line.79"></a>
+<FONT color="green">080</FONT> new DoublePoint(new double[] { 28.79359608888626, 10.36352064087987 }),<a name="line.80"></a>
+<FONT color="green">081</FONT> new DoublePoint(new double[] { 31.01284597092308, 12.788479208014905 }),<a name="line.81"></a>
+<FONT color="green">082</FONT> new DoublePoint(new double[] { 27.58509216737002, 11.47570110601373 }),<a name="line.82"></a>
+<FONT color="green">083</FONT> new DoublePoint(new double[] { 28.593799561727792, 10.780998203903437 }),<a name="line.83"></a>
+<FONT color="green">084</FONT> new DoublePoint(new double[] { 31.356105766724795, 15.080316198524088 }),<a name="line.84"></a>
+<FONT color="green">085</FONT> new DoublePoint(new double[] { 31.25948503636755, 13.674329151166603 }),<a name="line.85"></a>
+<FONT color="green">086</FONT> new DoublePoint(new double[] { 32.31590076372959, 14.95261758659035 }),<a name="line.86"></a>
+<FONT color="green">087</FONT> new DoublePoint(new double[] { 30.460413702763617, 15.88402809202671 }),<a name="line.87"></a>
+<FONT color="green">088</FONT> new DoublePoint(new double[] { 32.56178203062154, 14.586076852632686 }),<a name="line.88"></a>
+<FONT color="green">089</FONT> new DoublePoint(new double[] { 32.76138648530468, 16.239837325178087 }),<a name="line.89"></a>
+<FONT color="green">090</FONT> new DoublePoint(new double[] { 30.1829453331884, 14.709592407103628 }),<a name="line.90"></a>
+<FONT color="green">091</FONT> new DoublePoint(new double[] { 29.55088173528202, 15.0651247180067 }),<a name="line.91"></a>
+<FONT color="green">092</FONT> new DoublePoint(new double[] { 29.004155302187428, 14.089665298582986 }),<a name="line.92"></a>
+<FONT color="green">093</FONT> new DoublePoint(new double[] { 29.339624439831823, 13.29096065578051 }),<a name="line.93"></a>
+<FONT color="green">094</FONT> new DoublePoint(new double[] { 30.997460327576846, 14.551914158277214 }),<a name="line.94"></a>
+<FONT color="green">095</FONT> new DoublePoint(new double[] { 30.66784126125276, 16.269703107886016 })<a name="line.95"></a>
+<FONT color="green">096</FONT> };<a name="line.96"></a>
+<FONT color="green">097</FONT> <a name="line.97"></a>
+<FONT color="green">098</FONT> final DBSCANClusterer<DoublePoint> transformer =<a name="line.98"></a>
+<FONT color="green">099</FONT> new DBSCANClusterer<DoublePoint>(2.0, 5);<a name="line.99"></a>
+<FONT color="green">100</FONT> final List<Cluster<DoublePoint>> clusters = transformer.cluster(Arrays.asList(points));<a name="line.100"></a>
+<FONT color="green">101</FONT> <a name="line.101"></a>
+<FONT color="green">102</FONT> final List<DoublePoint> clusterOne =<a name="line.102"></a>
+<FONT color="green">103</FONT> Arrays.asList(points[3], points[4], points[5], points[6], points[7], points[8], points[9], points[10],<a name="line.103"></a>
+<FONT color="green">104</FONT> points[11], points[12], points[13], points[14]);<a name="line.104"></a>
+<FONT color="green">105</FONT> final List<DoublePoint> clusterTwo =<a name="line.105"></a>
+<FONT color="green">106</FONT> Arrays.asList(points[15], points[16], points[17], points[18], points[19], points[20], points[21],<a name="line.106"></a>
+<FONT color="green">107</FONT> points[22], points[23], points[24], points[25], points[26], points[27], points[28],<a name="line.107"></a>
+<FONT color="green">108</FONT> points[29], points[30], points[31], points[32], points[33], points[34], points[35],<a name="line.108"></a>
+<FONT color="green">109</FONT> points[36], points[37], points[38]);<a name="line.109"></a>
+<FONT color="green">110</FONT> final List<DoublePoint> clusterThree =<a name="line.110"></a>
+<FONT color="green">111</FONT> Arrays.asList(points[39], points[40], points[41], points[42], points[43], points[44], points[45],<a name="line.111"></a>
+<FONT color="green">112</FONT> points[46], points[47], points[48], points[49], points[50], points[51], points[52],<a name="line.112"></a>
+<FONT color="green">113</FONT> points[53], points[54], points[55], points[56], points[57], points[58], points[59],<a name="line.113"></a>
+<FONT color="green">114</FONT> points[60], points[61], points[62]);<a name="line.114"></a>
+<FONT color="green">115</FONT> <a name="line.115"></a>
+<FONT color="green">116</FONT> boolean cluster1Found = false;<a name="line.116"></a>
+<FONT color="green">117</FONT> boolean cluster2Found = false;<a name="line.117"></a>
+<FONT color="green">118</FONT> boolean cluster3Found = false;<a name="line.118"></a>
+<FONT color="green">119</FONT> Assert.assertEquals(3, clusters.size());<a name="line.119"></a>
+<FONT color="green">120</FONT> for (final Cluster<DoublePoint> cluster : clusters) {<a name="line.120"></a>
+<FONT color="green">121</FONT> if (cluster.getPoints().containsAll(clusterOne)) {<a name="line.121"></a>
+<FONT color="green">122</FONT> cluster1Found = true;<a name="line.122"></a>
+<FONT color="green">123</FONT> }<a name="line.123"></a>
+<FONT color="green">124</FONT> if (cluster.getPoints().containsAll(clusterTwo)) {<a name="line.124"></a>
+<FONT color="green">125</FONT> cluster2Found = true;<a name="line.125"></a>
+<FONT color="green">126</FONT> }<a name="line.126"></a>
+<FONT color="green">127</FONT> if (cluster.getPoints().containsAll(clusterThree)) {<a name="line.127"></a>
+<FONT color="green">128</FONT> cluster3Found = true;<a name="line.128"></a>
+<FONT color="green">129</FONT> }<a name="line.129"></a>
+<FONT color="green">130</FONT> }<a name="line.130"></a>
+<FONT color="green">131</FONT> Assert.assertTrue(cluster1Found);<a name="line.131"></a>
+<FONT color="green">132</FONT> Assert.assertTrue(cluster2Found);<a name="line.132"></a>
+<FONT color="green">133</FONT> Assert.assertTrue(cluster3Found);<a name="line.133"></a>
+<FONT color="green">134</FONT> }<a name="line.134"></a>
+<FONT color="green">135</FONT> <a name="line.135"></a>
+<FONT color="green">136</FONT> @Test<a name="line.136"></a>
+<FONT color="green">137</FONT> public void testSingleLink() {<a name="line.137"></a>
+<FONT color="green">138</FONT> final DoublePoint[] points = {<a name="line.138"></a>
+<FONT color="green">139</FONT> new DoublePoint(new int[] {10, 10}), // A<a name="line.139"></a>
+<FONT color="green">140</FONT> new DoublePoint(new int[] {12, 9}),<a name="line.140"></a>
+<FONT color="green">141</FONT> new DoublePoint(new int[] {10, 8}),<a name="line.141"></a>
+<FONT color="green">142</FONT> new DoublePoint(new int[] {8, 8}),<a name="line.142"></a>
+<FONT color="green">143</FONT> new DoublePoint(new int[] {8, 6}),<a name="line.143"></a>
+<FONT color="green">144</FONT> new DoublePoint(new int[] {7, 7}),<a name="line.144"></a>
+<FONT color="green">145</FONT> new DoublePoint(new int[] {5, 6}), // B<a name="line.145"></a>
+<FONT color="green">146</FONT> new DoublePoint(new int[] {14, 8}), // C<a name="line.146"></a>
+<FONT color="green">147</FONT> new DoublePoint(new int[] {7, 15}), // N - Noise, should not be present<a name="line.147"></a>
+<FONT color="green">148</FONT> new DoublePoint(new int[] {17, 8}), // D - single-link connected to C should not be present<a name="line.148"></a>
+<FONT color="green">149</FONT> <a name="line.149"></a>
+<FONT color="green">150</FONT> };<a name="line.150"></a>
+<FONT color="green">151</FONT> <a name="line.151"></a>
+<FONT color="green">152</FONT> final DBSCANClusterer<DoublePoint> clusterer = new DBSCANClusterer<DoublePoint>(3, 3);<a name="line.152"></a>
+<FONT color="green">153</FONT> List<Cluster<DoublePoint>> clusters = clusterer.cluster(Arrays.asList(points));<a name="line.153"></a>
+<FONT color="green">154</FONT> <a name="line.154"></a>
+<FONT color="green">155</FONT> Assert.assertEquals(1, clusters.size());<a name="line.155"></a>
+<FONT color="green">156</FONT> <a name="line.156"></a>
+<FONT color="green">157</FONT> final List<DoublePoint> clusterOne =<a name="line.157"></a>
+<FONT color="green">158</FONT> Arrays.asList(points[0], points[1], points[2], points[3], points[4], points[5], points[6], points[7]);<a name="line.158"></a>
+<FONT color="green">159</FONT> Assert.assertTrue(clusters.get(0).getPoints().containsAll(clusterOne));<a name="line.159"></a>
+<FONT color="green">160</FONT> }<a name="line.160"></a>
+<FONT color="green">161</FONT> <a name="line.161"></a>
+<FONT color="green">162</FONT> @Test<a name="line.162"></a>
+<FONT color="green">163</FONT> public void testGetEps() {<a name="line.163"></a>
+<FONT color="green">164</FONT> final DBSCANClusterer<DoublePoint> transformer = new DBSCANClusterer<DoublePoint>(2.0, 5);<a name="line.164"></a>
+<FONT color="green">165</FONT> Assert.assertEquals(2.0, transformer.getEps(), 0.0);<a name="line.165"></a>
+<FONT color="green">166</FONT> }<a name="line.166"></a>
+<FONT color="green">167</FONT> <a name="line.167"></a>
+<FONT color="green">168</FONT> @Test<a name="line.168"></a>
+<FONT color="green">169</FONT> public void testGetMinPts() {<a name="line.169"></a>
+<FONT color="green">170</FONT> final DBSCANClusterer<DoublePoint> transformer = new DBSCANClusterer<DoublePoint>(2.0, 5);<a name="line.170"></a>
+<FONT color="green">171</FONT> Assert.assertEquals(5, transformer.getMinPts());<a name="line.171"></a>
+<FONT color="green">172</FONT> }<a name="line.172"></a>
+<FONT color="green">173</FONT> <a name="line.173"></a>
+<FONT color="green">174</FONT> @Test(expected = MathIllegalArgumentException.class)<a name="line.174"></a>
+<FONT color="green">175</FONT> public void testNegativeEps() {<a name="line.175"></a>
+<FONT color="green">176</FONT> new DBSCANClusterer<DoublePoint>(-2.0, 5);<a name="line.176"></a>
+<FONT color="green">177</FONT> }<a name="line.177"></a>
+<FONT color="green">178</FONT> <a name="line.178"></a>
+<FONT color="green">179</FONT> @Test(expected = MathIllegalArgumentException.class)<a name="line.179"></a>
+<FONT color="green">180</FONT> public void testNegativeMinPts() {<a name="line.180"></a>
+<FONT color="green">181</FONT> new DBSCANClusterer<DoublePoint>(2.0, -5);<a name="line.181"></a>
+<FONT color="green">182</FONT> }<a name="line.182"></a>
+<FONT color="green">183</FONT> <a name="line.183"></a>
+<FONT color="green">184</FONT> @Test(expected = NullArgumentException.class)<a name="line.184"></a>
+<FONT color="green">185</FONT> public void testNullDataset() {<a name="line.185"></a>
+<FONT color="green">186</FONT> DBSCANClusterer<DoublePoint> clusterer = new DBSCANClusterer<DoublePoint>(2.0, 5);<a name="line.186"></a>
+<FONT color="green">187</FONT> clusterer.cluster(null);<a name="line.187"></a>
+<FONT color="green">188</FONT> }<a name="line.188"></a>
+<FONT color="green">189</FONT> <a name="line.189"></a>
+<FONT color="green">190</FONT> }<a name="line.190"></a>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+</PRE>
+</BODY>
+</HTML>
Propchange: websites/production/commons/content/proper/commons-math/testapidocs/src-html/org/apache/commons/math3/ml/clustering/DBSCANClustererTest.html
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: websites/production/commons/content/proper/commons-math/testapidocs/src-html/org/apache/commons/math3/ml/clustering/DBSCANClustererTest.html
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: websites/production/commons/content/proper/commons-math/testapidocs/src-html/org/apache/commons/math3/ml/clustering/KMeansPlusPlusClustererTest.html
==============================================================================
--- websites/production/commons/content/proper/commons-math/testapidocs/src-html/org/apache/commons/math3/ml/clustering/KMeansPlusPlusClustererTest.html (added)
+++ websites/production/commons/content/proper/commons-math/testapidocs/src-html/org/apache/commons/math3/ml/clustering/KMeansPlusPlusClustererTest.html Sat Apr 6 23:42:01 2013
@@ -0,0 +1,257 @@
+<HTML>
+<BODY BGCOLOR="white">
+<PRE>
+<FONT color="green">001</FONT> /*<a name="line.1"></a>
+<FONT color="green">002</FONT> * Licensed to the Apache Software Foundation (ASF) under one or more<a name="line.2"></a>
+<FONT color="green">003</FONT> * contributor license agreements. See the NOTICE file distributed with<a name="line.3"></a>
+<FONT color="green">004</FONT> * this work for additional information regarding copyright ownership.<a name="line.4"></a>
+<FONT color="green">005</FONT> * The ASF licenses this file to You under the Apache License, Version 2.0<a name="line.5"></a>
+<FONT color="green">006</FONT> * (the "License"); you may not use this file except in compliance with<a name="line.6"></a>
+<FONT color="green">007</FONT> * the License. You may obtain a copy of the License at<a name="line.7"></a>
+<FONT color="green">008</FONT> *<a name="line.8"></a>
+<FONT color="green">009</FONT> * http://www.apache.org/licenses/LICENSE-2.0<a name="line.9"></a>
+<FONT color="green">010</FONT> *<a name="line.10"></a>
+<FONT color="green">011</FONT> * Unless required by applicable law or agreed to in writing, software<a name="line.11"></a>
+<FONT color="green">012</FONT> * distributed under the License is distributed on an "AS IS" BASIS,<a name="line.12"></a>
+<FONT color="green">013</FONT> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<a name="line.13"></a>
+<FONT color="green">014</FONT> * See the License for the specific language governing permissions and<a name="line.14"></a>
+<FONT color="green">015</FONT> * limitations under the License.<a name="line.15"></a>
+<FONT color="green">016</FONT> */<a name="line.16"></a>
+<FONT color="green">017</FONT> <a name="line.17"></a>
+<FONT color="green">018</FONT> package org.apache.commons.math3.ml.clustering;<a name="line.18"></a>
+<FONT color="green">019</FONT> <a name="line.19"></a>
+<FONT color="green">020</FONT> import java.util.ArrayList;<a name="line.20"></a>
+<FONT color="green">021</FONT> import java.util.Arrays;<a name="line.21"></a>
+<FONT color="green">022</FONT> import java.util.Collection;<a name="line.22"></a>
+<FONT color="green">023</FONT> import java.util.List;<a name="line.23"></a>
+<FONT color="green">024</FONT> <a name="line.24"></a>
+<FONT color="green">025</FONT> import org.apache.commons.math3.exception.NumberIsTooSmallException;<a name="line.25"></a>
+<FONT color="green">026</FONT> import org.apache.commons.math3.ml.distance.EuclideanDistance;<a name="line.26"></a>
+<FONT color="green">027</FONT> import org.apache.commons.math3.random.JDKRandomGenerator;<a name="line.27"></a>
+<FONT color="green">028</FONT> import org.apache.commons.math3.random.RandomGenerator;<a name="line.28"></a>
+<FONT color="green">029</FONT> import org.junit.Assert;<a name="line.29"></a>
+<FONT color="green">030</FONT> import org.junit.Before;<a name="line.30"></a>
+<FONT color="green">031</FONT> import org.junit.Test;<a name="line.31"></a>
+<FONT color="green">032</FONT> <a name="line.32"></a>
+<FONT color="green">033</FONT> public class KMeansPlusPlusClustererTest {<a name="line.33"></a>
+<FONT color="green">034</FONT> <a name="line.34"></a>
+<FONT color="green">035</FONT> private RandomGenerator random;<a name="line.35"></a>
+<FONT color="green">036</FONT> <a name="line.36"></a>
+<FONT color="green">037</FONT> @Before<a name="line.37"></a>
+<FONT color="green">038</FONT> public void setUp() {<a name="line.38"></a>
+<FONT color="green">039</FONT> random = new JDKRandomGenerator();<a name="line.39"></a>
+<FONT color="green">040</FONT> random.setSeed(1746432956321l); <a name="line.40"></a>
+<FONT color="green">041</FONT> }<a name="line.41"></a>
+<FONT color="green">042</FONT> <a name="line.42"></a>
+<FONT color="green">043</FONT> /**<a name="line.43"></a>
+<FONT color="green">044</FONT> * JIRA: MATH-305<a name="line.44"></a>
+<FONT color="green">045</FONT> *<a name="line.45"></a>
+<FONT color="green">046</FONT> * Two points, one cluster, one iteration<a name="line.46"></a>
+<FONT color="green">047</FONT> */<a name="line.47"></a>
+<FONT color="green">048</FONT> @Test<a name="line.48"></a>
+<FONT color="green">049</FONT> public void testPerformClusterAnalysisDegenerate() {<a name="line.49"></a>
+<FONT color="green">050</FONT> KMeansPlusPlusClusterer<DoublePoint> transformer =<a name="line.50"></a>
+<FONT color="green">051</FONT> new KMeansPlusPlusClusterer<DoublePoint>(1, 1);<a name="line.51"></a>
+<FONT color="green">052</FONT> <a name="line.52"></a>
+<FONT color="green">053</FONT> DoublePoint[] points = new DoublePoint[] {<a name="line.53"></a>
+<FONT color="green">054</FONT> new DoublePoint(new int[] { 1959, 325100 }),<a name="line.54"></a>
+<FONT color="green">055</FONT> new DoublePoint(new int[] { 1960, 373200 }), };<a name="line.55"></a>
+<FONT color="green">056</FONT> List<? extends Cluster<DoublePoint>> clusters = transformer.cluster(Arrays.asList(points));<a name="line.56"></a>
+<FONT color="green">057</FONT> Assert.assertEquals(1, clusters.size());<a name="line.57"></a>
+<FONT color="green">058</FONT> Assert.assertEquals(2, (clusters.get(0).getPoints().size()));<a name="line.58"></a>
+<FONT color="green">059</FONT> DoublePoint pt1 = new DoublePoint(new int[] { 1959, 325100 });<a name="line.59"></a>
+<FONT color="green">060</FONT> DoublePoint pt2 = new DoublePoint(new int[] { 1960, 373200 });<a name="line.60"></a>
+<FONT color="green">061</FONT> Assert.assertTrue(clusters.get(0).getPoints().contains(pt1));<a name="line.61"></a>
+<FONT color="green">062</FONT> Assert.assertTrue(clusters.get(0).getPoints().contains(pt2));<a name="line.62"></a>
+<FONT color="green">063</FONT> <a name="line.63"></a>
+<FONT color="green">064</FONT> }<a name="line.64"></a>
+<FONT color="green">065</FONT> <a name="line.65"></a>
+<FONT color="green">066</FONT> @Test<a name="line.66"></a>
+<FONT color="green">067</FONT> public void testCertainSpace() {<a name="line.67"></a>
+<FONT color="green">068</FONT> KMeansPlusPlusClusterer.EmptyClusterStrategy[] strategies = {<a name="line.68"></a>
+<FONT color="green">069</FONT> KMeansPlusPlusClusterer.EmptyClusterStrategy.LARGEST_VARIANCE,<a name="line.69"></a>
+<FONT color="green">070</FONT> KMeansPlusPlusClusterer.EmptyClusterStrategy.LARGEST_POINTS_NUMBER,<a name="line.70"></a>
+<FONT color="green">071</FONT> KMeansPlusPlusClusterer.EmptyClusterStrategy.FARTHEST_POINT<a name="line.71"></a>
+<FONT color="green">072</FONT> };<a name="line.72"></a>
+<FONT color="green">073</FONT> for (KMeansPlusPlusClusterer.EmptyClusterStrategy strategy : strategies) {<a name="line.73"></a>
+<FONT color="green">074</FONT> int numberOfVariables = 27;<a name="line.74"></a>
+<FONT color="green">075</FONT> // initialise testvalues<a name="line.75"></a>
+<FONT color="green">076</FONT> int position1 = 1;<a name="line.76"></a>
+<FONT color="green">077</FONT> int position2 = position1 + numberOfVariables;<a name="line.77"></a>
+<FONT color="green">078</FONT> int position3 = position2 + numberOfVariables;<a name="line.78"></a>
+<FONT color="green">079</FONT> int position4 = position3 + numberOfVariables;<a name="line.79"></a>
+<FONT color="green">080</FONT> // testvalues will be multiplied<a name="line.80"></a>
+<FONT color="green">081</FONT> int multiplier = 1000000;<a name="line.81"></a>
+<FONT color="green">082</FONT> <a name="line.82"></a>
+<FONT color="green">083</FONT> DoublePoint[] breakingPoints = new DoublePoint[numberOfVariables];<a name="line.83"></a>
+<FONT color="green">084</FONT> // define the space which will break the cluster algorithm<a name="line.84"></a>
+<FONT color="green">085</FONT> for (int i = 0; i < numberOfVariables; i++) {<a name="line.85"></a>
+<FONT color="green">086</FONT> int points[] = { position1, position2, position3, position4 };<a name="line.86"></a>
+<FONT color="green">087</FONT> // multiply the values<a name="line.87"></a>
+<FONT color="green">088</FONT> for (int j = 0; j < points.length; j++) {<a name="line.88"></a>
+<FONT color="green">089</FONT> points[j] = points[j] * multiplier;<a name="line.89"></a>
+<FONT color="green">090</FONT> }<a name="line.90"></a>
+<FONT color="green">091</FONT> DoublePoint DoublePoint = new DoublePoint(points);<a name="line.91"></a>
+<FONT color="green">092</FONT> breakingPoints[i] = DoublePoint;<a name="line.92"></a>
+<FONT color="green">093</FONT> position1 = position1 + numberOfVariables;<a name="line.93"></a>
+<FONT color="green">094</FONT> position2 = position2 + numberOfVariables;<a name="line.94"></a>
+<FONT color="green">095</FONT> position3 = position3 + numberOfVariables;<a name="line.95"></a>
+<FONT color="green">096</FONT> position4 = position4 + numberOfVariables;<a name="line.96"></a>
+<FONT color="green">097</FONT> }<a name="line.97"></a>
+<FONT color="green">098</FONT> <a name="line.98"></a>
+<FONT color="green">099</FONT> for (int n = 2; n < 27; ++n) {<a name="line.99"></a>
+<FONT color="green">100</FONT> KMeansPlusPlusClusterer<DoublePoint> transformer =<a name="line.100"></a>
+<FONT color="green">101</FONT> new KMeansPlusPlusClusterer<DoublePoint>(n, 100, new EuclideanDistance(), random, strategy);<a name="line.101"></a>
+<FONT color="green">102</FONT> <a name="line.102"></a>
+<FONT color="green">103</FONT> List<? extends Cluster<DoublePoint>> clusters =<a name="line.103"></a>
+<FONT color="green">104</FONT> transformer.cluster(Arrays.asList(breakingPoints));<a name="line.104"></a>
+<FONT color="green">105</FONT> <a name="line.105"></a>
+<FONT color="green">106</FONT> Assert.assertEquals(n, clusters.size());<a name="line.106"></a>
+<FONT color="green">107</FONT> int sum = 0;<a name="line.107"></a>
+<FONT color="green">108</FONT> for (Cluster<DoublePoint> cluster : clusters) {<a name="line.108"></a>
+<FONT color="green">109</FONT> sum += cluster.getPoints().size();<a name="line.109"></a>
+<FONT color="green">110</FONT> }<a name="line.110"></a>
+<FONT color="green">111</FONT> Assert.assertEquals(numberOfVariables, sum);<a name="line.111"></a>
+<FONT color="green">112</FONT> }<a name="line.112"></a>
+<FONT color="green">113</FONT> }<a name="line.113"></a>
+<FONT color="green">114</FONT> <a name="line.114"></a>
+<FONT color="green">115</FONT> }<a name="line.115"></a>
+<FONT color="green">116</FONT> <a name="line.116"></a>
+<FONT color="green">117</FONT> /**<a name="line.117"></a>
+<FONT color="green">118</FONT> * A helper class for testSmallDistances(). This class is similar to DoublePoint, but<a name="line.118"></a>
+<FONT color="green">119</FONT> * it defines a different distanceFrom() method that tends to return distances less than 1.<a name="line.119"></a>
+<FONT color="green">120</FONT> */<a name="line.120"></a>
+<FONT color="green">121</FONT> private class CloseDistance extends EuclideanDistance {<a name="line.121"></a>
+<FONT color="green">122</FONT> private static final long serialVersionUID = 1L;<a name="line.122"></a>
+<FONT color="green">123</FONT> <a name="line.123"></a>
+<FONT color="green">124</FONT> @Override<a name="line.124"></a>
+<FONT color="green">125</FONT> public double compute(double[] a, double[] b) {<a name="line.125"></a>
+<FONT color="green">126</FONT> return super.compute(a, b) * 0.001;<a name="line.126"></a>
+<FONT color="green">127</FONT> }<a name="line.127"></a>
+<FONT color="green">128</FONT> }<a name="line.128"></a>
+<FONT color="green">129</FONT> <a name="line.129"></a>
+<FONT color="green">130</FONT> /**<a name="line.130"></a>
+<FONT color="green">131</FONT> * Test points that are very close together. See issue MATH-546.<a name="line.131"></a>
+<FONT color="green">132</FONT> */<a name="line.132"></a>
+<FONT color="green">133</FONT> @Test<a name="line.133"></a>
+<FONT color="green">134</FONT> public void testSmallDistances() {<a name="line.134"></a>
+<FONT color="green">135</FONT> // Create a bunch of CloseDoublePoints. Most are identical, but one is different by a<a name="line.135"></a>
+<FONT color="green">136</FONT> // small distance.<a name="line.136"></a>
+<FONT color="green">137</FONT> int[] repeatedArray = { 0 };<a name="line.137"></a>
+<FONT color="green">138</FONT> int[] uniqueArray = { 1 };<a name="line.138"></a>
+<FONT color="green">139</FONT> DoublePoint repeatedPoint = new DoublePoint(repeatedArray);<a name="line.139"></a>
+<FONT color="green">140</FONT> DoublePoint uniquePoint = new DoublePoint(uniqueArray);<a name="line.140"></a>
+<FONT color="green">141</FONT> <a name="line.141"></a>
+<FONT color="green">142</FONT> Collection<DoublePoint> points = new ArrayList<DoublePoint>();<a name="line.142"></a>
+<FONT color="green">143</FONT> final int NUM_REPEATED_POINTS = 10 * 1000;<a name="line.143"></a>
+<FONT color="green">144</FONT> for (int i = 0; i < NUM_REPEATED_POINTS; ++i) {<a name="line.144"></a>
+<FONT color="green">145</FONT> points.add(repeatedPoint);<a name="line.145"></a>
+<FONT color="green">146</FONT> }<a name="line.146"></a>
+<FONT color="green">147</FONT> points.add(uniquePoint);<a name="line.147"></a>
+<FONT color="green">148</FONT> <a name="line.148"></a>
+<FONT color="green">149</FONT> // Ask a KMeansPlusPlusClusterer to run zero iterations (i.e., to simply choose initial<a name="line.149"></a>
+<FONT color="green">150</FONT> // cluster centers).<a name="line.150"></a>
+<FONT color="green">151</FONT> final long RANDOM_SEED = 0;<a name="line.151"></a>
+<FONT color="green">152</FONT> final int NUM_CLUSTERS = 2;<a name="line.152"></a>
+<FONT color="green">153</FONT> final int NUM_ITERATIONS = 0;<a name="line.153"></a>
+<FONT color="green">154</FONT> random.setSeed(RANDOM_SEED);<a name="line.154"></a>
+<FONT color="green">155</FONT> <a name="line.155"></a>
+<FONT color="green">156</FONT> KMeansPlusPlusClusterer<DoublePoint> clusterer =<a name="line.156"></a>
+<FONT color="green">157</FONT> new KMeansPlusPlusClusterer<DoublePoint>(NUM_CLUSTERS, NUM_ITERATIONS,<a name="line.157"></a>
+<FONT color="green">158</FONT> new CloseDistance(), random);<a name="line.158"></a>
+<FONT color="green">159</FONT> List<CentroidCluster<DoublePoint>> clusters = clusterer.cluster(points);<a name="line.159"></a>
+<FONT color="green">160</FONT> <a name="line.160"></a>
+<FONT color="green">161</FONT> // Check that one of the chosen centers is the unique point.<a name="line.161"></a>
+<FONT color="green">162</FONT> boolean uniquePointIsCenter = false;<a name="line.162"></a>
+<FONT color="green">163</FONT> for (CentroidCluster<DoublePoint> cluster : clusters) {<a name="line.163"></a>
+<FONT color="green">164</FONT> if (cluster.getCenter().equals(uniquePoint)) {<a name="line.164"></a>
+<FONT color="green">165</FONT> uniquePointIsCenter = true;<a name="line.165"></a>
+<FONT color="green">166</FONT> }<a name="line.166"></a>
+<FONT color="green">167</FONT> }<a name="line.167"></a>
+<FONT color="green">168</FONT> Assert.assertTrue(uniquePointIsCenter);<a name="line.168"></a>
+<FONT color="green">169</FONT> }<a name="line.169"></a>
+<FONT color="green">170</FONT> <a name="line.170"></a>
+<FONT color="green">171</FONT> /**<a name="line.171"></a>
+<FONT color="green">172</FONT> * 2 variables cannot be clustered into 3 clusters. See issue MATH-436.<a name="line.172"></a>
+<FONT color="green">173</FONT> */<a name="line.173"></a>
+<FONT color="green">174</FONT> @Test(expected=NumberIsTooSmallException.class)<a name="line.174"></a>
+<FONT color="green">175</FONT> public void testPerformClusterAnalysisToManyClusters() {<a name="line.175"></a>
+<FONT color="green">176</FONT> KMeansPlusPlusClusterer<DoublePoint> transformer = <a name="line.176"></a>
+<FONT color="green">177</FONT> new KMeansPlusPlusClusterer<DoublePoint>(3, 1, new EuclideanDistance(), random);<a name="line.177"></a>
+<FONT color="green">178</FONT> <a name="line.178"></a>
+<FONT color="green">179</FONT> DoublePoint[] points = new DoublePoint[] {<a name="line.179"></a>
+<FONT color="green">180</FONT> new DoublePoint(new int[] {<a name="line.180"></a>
+<FONT color="green">181</FONT> 1959, 325100<a name="line.181"></a>
+<FONT color="green">182</FONT> }), new DoublePoint(new int[] {<a name="line.182"></a>
+<FONT color="green">183</FONT> 1960, 373200<a name="line.183"></a>
+<FONT color="green">184</FONT> })<a name="line.184"></a>
+<FONT color="green">185</FONT> };<a name="line.185"></a>
+<FONT color="green">186</FONT> <a name="line.186"></a>
+<FONT color="green">187</FONT> transformer.cluster(Arrays.asList(points));<a name="line.187"></a>
+<FONT color="green">188</FONT> <a name="line.188"></a>
+<FONT color="green">189</FONT> }<a name="line.189"></a>
+<FONT color="green">190</FONT> <a name="line.190"></a>
+<FONT color="green">191</FONT> }<a name="line.191"></a>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+</PRE>
+</BODY>
+</HTML>
Propchange: websites/production/commons/content/proper/commons-math/testapidocs/src-html/org/apache/commons/math3/ml/clustering/KMeansPlusPlusClustererTest.html
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: websites/production/commons/content/proper/commons-math/testapidocs/src-html/org/apache/commons/math3/ml/clustering/KMeansPlusPlusClustererTest.html
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: websites/production/commons/content/proper/commons-math/testapidocs/src-html/org/apache/commons/math3/ml/clustering/MultiKMeansPlusPlusClustererTest.html
==============================================================================
--- websites/production/commons/content/proper/commons-math/testapidocs/src-html/org/apache/commons/math3/ml/clustering/MultiKMeansPlusPlusClustererTest.html (added)
+++ websites/production/commons/content/proper/commons-math/testapidocs/src-html/org/apache/commons/math3/ml/clustering/MultiKMeansPlusPlusClustererTest.html Sat Apr 6 23:42:01 2013
@@ -0,0 +1,164 @@
+<HTML>
+<BODY BGCOLOR="white">
+<PRE>
+<FONT color="green">001</FONT> /*<a name="line.1"></a>
+<FONT color="green">002</FONT> * Licensed to the Apache Software Foundation (ASF) under one or more<a name="line.2"></a>
+<FONT color="green">003</FONT> * contributor license agreements. See the NOTICE file distributed with<a name="line.3"></a>
+<FONT color="green">004</FONT> * this work for additional information regarding copyright ownership.<a name="line.4"></a>
+<FONT color="green">005</FONT> * The ASF licenses this file to You under the Apache License, Version 2.0<a name="line.5"></a>
+<FONT color="green">006</FONT> * (the "License"); you may not use this file except in compliance with<a name="line.6"></a>
+<FONT color="green">007</FONT> * the License. You may obtain a copy of the License at<a name="line.7"></a>
+<FONT color="green">008</FONT> *<a name="line.8"></a>
+<FONT color="green">009</FONT> * http://www.apache.org/licenses/LICENSE-2.0<a name="line.9"></a>
+<FONT color="green">010</FONT> *<a name="line.10"></a>
+<FONT color="green">011</FONT> * Unless required by applicable law or agreed to in writing, software<a name="line.11"></a>
+<FONT color="green">012</FONT> * distributed under the License is distributed on an "AS IS" BASIS,<a name="line.12"></a>
+<FONT color="green">013</FONT> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<a name="line.13"></a>
+<FONT color="green">014</FONT> * See the License for the specific language governing permissions and<a name="line.14"></a>
+<FONT color="green">015</FONT> * limitations under the License.<a name="line.15"></a>
+<FONT color="green">016</FONT> */<a name="line.16"></a>
+<FONT color="green">017</FONT> <a name="line.17"></a>
+<FONT color="green">018</FONT> package org.apache.commons.math3.ml.clustering;<a name="line.18"></a>
+<FONT color="green">019</FONT> <a name="line.19"></a>
+<FONT color="green">020</FONT> <a name="line.20"></a>
+<FONT color="green">021</FONT> import java.util.Arrays;<a name="line.21"></a>
+<FONT color="green">022</FONT> import java.util.List;<a name="line.22"></a>
+<FONT color="green">023</FONT> <a name="line.23"></a>
+<FONT color="green">024</FONT> import org.junit.Assert;<a name="line.24"></a>
+<FONT color="green">025</FONT> import org.junit.Test;<a name="line.25"></a>
+<FONT color="green">026</FONT> <a name="line.26"></a>
+<FONT color="green">027</FONT> public class MultiKMeansPlusPlusClustererTest {<a name="line.27"></a>
+<FONT color="green">028</FONT> <a name="line.28"></a>
+<FONT color="green">029</FONT> @Test<a name="line.29"></a>
+<FONT color="green">030</FONT> public void dimension2() {<a name="line.30"></a>
+<FONT color="green">031</FONT> MultiKMeansPlusPlusClusterer<DoublePoint> transformer =<a name="line.31"></a>
+<FONT color="green">032</FONT> new MultiKMeansPlusPlusClusterer<DoublePoint>(<a name="line.32"></a>
+<FONT color="green">033</FONT> new KMeansPlusPlusClusterer<DoublePoint>(3, 10), 5);<a name="line.33"></a>
+<FONT color="green">034</FONT> <a name="line.34"></a>
+<FONT color="green">035</FONT> DoublePoint[] points = new DoublePoint[] {<a name="line.35"></a>
+<FONT color="green">036</FONT> <a name="line.36"></a>
+<FONT color="green">037</FONT> // first expected cluster<a name="line.37"></a>
+<FONT color="green">038</FONT> new DoublePoint(new int[] { -15, 3 }),<a name="line.38"></a>
+<FONT color="green">039</FONT> new DoublePoint(new int[] { -15, 4 }),<a name="line.39"></a>
+<FONT color="green">040</FONT> new DoublePoint(new int[] { -15, 5 }),<a name="line.40"></a>
+<FONT color="green">041</FONT> new DoublePoint(new int[] { -14, 3 }),<a name="line.41"></a>
+<FONT color="green">042</FONT> new DoublePoint(new int[] { -14, 5 }),<a name="line.42"></a>
+<FONT color="green">043</FONT> new DoublePoint(new int[] { -13, 3 }),<a name="line.43"></a>
+<FONT color="green">044</FONT> new DoublePoint(new int[] { -13, 4 }),<a name="line.44"></a>
+<FONT color="green">045</FONT> new DoublePoint(new int[] { -13, 5 }),<a name="line.45"></a>
+<FONT color="green">046</FONT> <a name="line.46"></a>
+<FONT color="green">047</FONT> // second expected cluster<a name="line.47"></a>
+<FONT color="green">048</FONT> new DoublePoint(new int[] { -1, 0 }),<a name="line.48"></a>
+<FONT color="green">049</FONT> new DoublePoint(new int[] { -1, -1 }),<a name="line.49"></a>
+<FONT color="green">050</FONT> new DoublePoint(new int[] { 0, -1 }),<a name="line.50"></a>
+<FONT color="green">051</FONT> new DoublePoint(new int[] { 1, -1 }),<a name="line.51"></a>
+<FONT color="green">052</FONT> new DoublePoint(new int[] { 1, -2 }),<a name="line.52"></a>
+<FONT color="green">053</FONT> <a name="line.53"></a>
+<FONT color="green">054</FONT> // third expected cluster<a name="line.54"></a>
+<FONT color="green">055</FONT> new DoublePoint(new int[] { 13, 3 }),<a name="line.55"></a>
+<FONT color="green">056</FONT> new DoublePoint(new int[] { 13, 4 }),<a name="line.56"></a>
+<FONT color="green">057</FONT> new DoublePoint(new int[] { 14, 4 }),<a name="line.57"></a>
+<FONT color="green">058</FONT> new DoublePoint(new int[] { 14, 7 }),<a name="line.58"></a>
+<FONT color="green">059</FONT> new DoublePoint(new int[] { 16, 5 }),<a name="line.59"></a>
+<FONT color="green">060</FONT> new DoublePoint(new int[] { 16, 6 }),<a name="line.60"></a>
+<FONT color="green">061</FONT> new DoublePoint(new int[] { 17, 4 }),<a name="line.61"></a>
+<FONT color="green">062</FONT> new DoublePoint(new int[] { 17, 7 })<a name="line.62"></a>
+<FONT color="green">063</FONT> <a name="line.63"></a>
+<FONT color="green">064</FONT> };<a name="line.64"></a>
+<FONT color="green">065</FONT> List<CentroidCluster<DoublePoint>> clusters = transformer.cluster(Arrays.asList(points));<a name="line.65"></a>
+<FONT color="green">066</FONT> <a name="line.66"></a>
+<FONT color="green">067</FONT> Assert.assertEquals(3, clusters.size());<a name="line.67"></a>
+<FONT color="green">068</FONT> boolean cluster1Found = false;<a name="line.68"></a>
+<FONT color="green">069</FONT> boolean cluster2Found = false;<a name="line.69"></a>
+<FONT color="green">070</FONT> boolean cluster3Found = false;<a name="line.70"></a>
+<FONT color="green">071</FONT> double epsilon = 1e-6;<a name="line.71"></a>
+<FONT color="green">072</FONT> for (CentroidCluster<DoublePoint> cluster : clusters) {<a name="line.72"></a>
+<FONT color="green">073</FONT> Clusterable center = cluster.getCenter();<a name="line.73"></a>
+<FONT color="green">074</FONT> double[] point = center.getPoint();<a name="line.74"></a>
+<FONT color="green">075</FONT> if (point[0] < 0) {<a name="line.75"></a>
+<FONT color="green">076</FONT> cluster1Found = true;<a name="line.76"></a>
+<FONT color="green">077</FONT> Assert.assertEquals(8, cluster.getPoints().size());<a name="line.77"></a>
+<FONT color="green">078</FONT> Assert.assertEquals(-14, point[0], epsilon);<a name="line.78"></a>
+<FONT color="green">079</FONT> Assert.assertEquals( 4, point[1], epsilon);<a name="line.79"></a>
+<FONT color="green">080</FONT> } else if (point[1] < 0) {<a name="line.80"></a>
+<FONT color="green">081</FONT> cluster2Found = true;<a name="line.81"></a>
+<FONT color="green">082</FONT> Assert.assertEquals(5, cluster.getPoints().size());<a name="line.82"></a>
+<FONT color="green">083</FONT> Assert.assertEquals( 0, point[0], epsilon);<a name="line.83"></a>
+<FONT color="green">084</FONT> Assert.assertEquals(-1, point[1], epsilon);<a name="line.84"></a>
+<FONT color="green">085</FONT> } else {<a name="line.85"></a>
+<FONT color="green">086</FONT> cluster3Found = true;<a name="line.86"></a>
+<FONT color="green">087</FONT> Assert.assertEquals(8, cluster.getPoints().size());<a name="line.87"></a>
+<FONT color="green">088</FONT> Assert.assertEquals(15, point[0], epsilon);<a name="line.88"></a>
+<FONT color="green">089</FONT> Assert.assertEquals(5, point[1], epsilon);<a name="line.89"></a>
+<FONT color="green">090</FONT> }<a name="line.90"></a>
+<FONT color="green">091</FONT> }<a name="line.91"></a>
+<FONT color="green">092</FONT> Assert.assertTrue(cluster1Found);<a name="line.92"></a>
+<FONT color="green">093</FONT> Assert.assertTrue(cluster2Found);<a name="line.93"></a>
+<FONT color="green">094</FONT> Assert.assertTrue(cluster3Found);<a name="line.94"></a>
+<FONT color="green">095</FONT> <a name="line.95"></a>
+<FONT color="green">096</FONT> }<a name="line.96"></a>
+<FONT color="green">097</FONT> <a name="line.97"></a>
+<FONT color="green">098</FONT> }<a name="line.98"></a>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+</PRE>
+</BODY>
+</HTML>
Propchange: websites/production/commons/content/proper/commons-math/testapidocs/src-html/org/apache/commons/math3/ml/clustering/MultiKMeansPlusPlusClustererTest.html
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: websites/production/commons/content/proper/commons-math/testapidocs/src-html/org/apache/commons/math3/ml/clustering/MultiKMeansPlusPlusClustererTest.html
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: websites/production/commons/content/proper/commons-math/testapidocs/src-html/org/apache/commons/math3/ml/distance/CanberraDistanceTest.html
==============================================================================
--- websites/production/commons/content/proper/commons-math/testapidocs/src-html/org/apache/commons/math3/ml/distance/CanberraDistanceTest.html (added)
+++ websites/production/commons/content/proper/commons-math/testapidocs/src-html/org/apache/commons/math3/ml/distance/CanberraDistanceTest.html Sat Apr 6 23:42:01 2013
@@ -0,0 +1,114 @@
+<HTML>
+<BODY BGCOLOR="white">
+<PRE>
+<FONT color="green">001</FONT> /*<a name="line.1"></a>
+<FONT color="green">002</FONT> * Licensed to the Apache Software Foundation (ASF) under one or more<a name="line.2"></a>
+<FONT color="green">003</FONT> * contributor license agreements. See the NOTICE file distributed with<a name="line.3"></a>
+<FONT color="green">004</FONT> * this work for additional information regarding copyright ownership.<a name="line.4"></a>
+<FONT color="green">005</FONT> * The ASF licenses this file to You under the Apache License, Version 2.0<a name="line.5"></a>
+<FONT color="green">006</FONT> * (the "License"); you may not use this file except in compliance with<a name="line.6"></a>
+<FONT color="green">007</FONT> * the License. You may obtain a copy of the License at<a name="line.7"></a>
+<FONT color="green">008</FONT> *<a name="line.8"></a>
+<FONT color="green">009</FONT> * http://www.apache.org/licenses/LICENSE-2.0<a name="line.9"></a>
+<FONT color="green">010</FONT> *<a name="line.10"></a>
+<FONT color="green">011</FONT> * Unless required by applicable law or agreed to in writing, software<a name="line.11"></a>
+<FONT color="green">012</FONT> * distributed under the License is distributed on an "AS IS" BASIS,<a name="line.12"></a>
+<FONT color="green">013</FONT> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<a name="line.13"></a>
+<FONT color="green">014</FONT> * See the License for the specific language governing permissions and<a name="line.14"></a>
+<FONT color="green">015</FONT> * limitations under the License.<a name="line.15"></a>
+<FONT color="green">016</FONT> */<a name="line.16"></a>
+<FONT color="green">017</FONT> package org.apache.commons.math3.ml.distance;<a name="line.17"></a>
+<FONT color="green">018</FONT> <a name="line.18"></a>
+<FONT color="green">019</FONT> import org.junit.Assert;<a name="line.19"></a>
+<FONT color="green">020</FONT> import org.junit.Test;<a name="line.20"></a>
+<FONT color="green">021</FONT> <a name="line.21"></a>
+<FONT color="green">022</FONT> /**<a name="line.22"></a>
+<FONT color="green">023</FONT> * Tests for {@link CanberraDistance} class.<a name="line.23"></a>
+<FONT color="green">024</FONT> */<a name="line.24"></a>
+<FONT color="green">025</FONT> public class CanberraDistanceTest {<a name="line.25"></a>
+<FONT color="green">026</FONT> final DistanceMeasure distance = new CanberraDistance();<a name="line.26"></a>
+<FONT color="green">027</FONT> <a name="line.27"></a>
+<FONT color="green">028</FONT> @Test<a name="line.28"></a>
+<FONT color="green">029</FONT> public void testZero() {<a name="line.29"></a>
+<FONT color="green">030</FONT> final double[] a = { 0, 1, -2, 3.4, 5, -6.7, 89 };<a name="line.30"></a>
+<FONT color="green">031</FONT> Assert.assertEquals(0, distance.compute(a, a), 0d);<a name="line.31"></a>
+<FONT color="green">032</FONT> }<a name="line.32"></a>
+<FONT color="green">033</FONT> <a name="line.33"></a>
+<FONT color="green">034</FONT> @Test<a name="line.34"></a>
+<FONT color="green">035</FONT> public void testZero2() {<a name="line.35"></a>
+<FONT color="green">036</FONT> final double[] a = { 0, 0 };<a name="line.36"></a>
+<FONT color="green">037</FONT> Assert.assertEquals(0, distance.compute(a, a), 0d);<a name="line.37"></a>
+<FONT color="green">038</FONT> }<a name="line.38"></a>
+<FONT color="green">039</FONT> <a name="line.39"></a>
+<FONT color="green">040</FONT> @Test<a name="line.40"></a>
+<FONT color="green">041</FONT> public void test() {<a name="line.41"></a>
+<FONT color="green">042</FONT> final double[] a = { 1, 2, 3, 4, 9 };<a name="line.42"></a>
+<FONT color="green">043</FONT> final double[] b = { -5, -6, 7, 4, 3 };<a name="line.43"></a>
+<FONT color="green">044</FONT> final double expected = 2.9;<a name="line.44"></a>
+<FONT color="green">045</FONT> Assert.assertEquals(expected, distance.compute(a, b), 0d);<a name="line.45"></a>
+<FONT color="green">046</FONT> Assert.assertEquals(expected, distance.compute(b, a), 0d);<a name="line.46"></a>
+<FONT color="green">047</FONT> }<a name="line.47"></a>
+<FONT color="green">048</FONT> }<a name="line.48"></a>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+</PRE>
+</BODY>
+</HTML>
Propchange: websites/production/commons/content/proper/commons-math/testapidocs/src-html/org/apache/commons/math3/ml/distance/CanberraDistanceTest.html
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: websites/production/commons/content/proper/commons-math/testapidocs/src-html/org/apache/commons/math3/ml/distance/CanberraDistanceTest.html
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision