classifier 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +361 -273
- data/README +6 -5
- data/Rakefile +12 -2
- data/bin/summarize.rb +11 -0
- data/doc/classes/Array.html +139 -0
- data/doc/classes/Array.src/M000003.html +18 -0
- data/doc/classes/Classifier.html +5 -5
- data/doc/classes/Classifier/Bayes.html +43 -43
- data/doc/classes/Classifier/Bayes.src/{M000023.html → M000038.html} +0 -0
- data/doc/classes/Classifier/Bayes.src/{M000024.html → M000039.html} +0 -0
- data/doc/classes/Classifier/Bayes.src/{M000025.html → M000040.html} +0 -0
- data/doc/classes/Classifier/Bayes.src/{M000026.html → M000041.html} +0 -0
- data/doc/classes/Classifier/Bayes.src/{M000027.html → M000042.html} +0 -0
- data/doc/classes/Classifier/Bayes.src/{M000028.html → M000043.html} +0 -0
- data/doc/classes/Classifier/Bayes.src/{M000029.html → M000044.html} +0 -0
- data/doc/classes/Classifier/ContentNode.html +23 -28
- data/doc/classes/Classifier/ContentNode.src/M000046.html +19 -0
- data/doc/classes/Classifier/ContentNode.src/{M000032.html → M000047.html} +1 -1
- data/doc/classes/Classifier/ContentNode.src/{M000033.html → M000048.html} +1 -1
- data/doc/classes/Classifier/ContentNode.src/M000049.html +49 -0
- data/doc/classes/Classifier/LSI.html +158 -68
- data/doc/classes/Classifier/LSI.src/M000022.html +6 -17
- data/doc/classes/Classifier/LSI.src/{M000012.html → M000023.html} +2 -2
- data/doc/classes/Classifier/LSI.src/{M000013.html → M000024.html} +3 -2
- data/doc/classes/Classifier/LSI.src/{M000014.html → M000025.html} +1 -1
- data/doc/classes/Classifier/LSI.src/M000026.html +19 -0
- data/doc/classes/Classifier/LSI.src/{M000015.html → M000027.html} +1 -1
- data/doc/classes/Classifier/LSI.src/{M000016.html → M000028.html} +1 -1
- data/doc/classes/Classifier/LSI.src/M000029.html +19 -0
- data/doc/classes/Classifier/LSI.src/M000030.html +43 -0
- data/doc/classes/Classifier/LSI.src/M000031.html +23 -0
- data/doc/classes/Classifier/LSI.src/{M000018.html → M000032.html} +7 -3
- data/doc/classes/Classifier/LSI.src/{M000019.html → M000033.html} +6 -2
- data/doc/classes/Classifier/LSI.src/{M000020.html → M000034.html} +2 -4
- data/doc/classes/Classifier/LSI.src/{M000021.html → M000035.html} +1 -1
- data/doc/classes/Classifier/LSI.src/M000036.html +31 -0
- data/doc/classes/Classifier/LSI.src/M000037.html +21 -0
- data/doc/classes/Classifier/WordList.html +37 -22
- data/doc/classes/Classifier/WordList.src/{M000007.html → M000017.html} +2 -2
- data/doc/classes/Classifier/WordList.src/{M000008.html → M000018.html} +1 -1
- data/doc/classes/Classifier/WordList.src/{M000009.html → M000019.html} +1 -1
- data/doc/classes/Classifier/WordList.src/M000020.html +18 -0
- data/doc/classes/Classifier/WordList.src/{M000010.html → M000021.html} +1 -1
- data/doc/classes/GSL.html +2 -1
- data/doc/classes/GSL/Matrix.html +126 -0
- data/doc/classes/GSL/Vector.html +10 -10
- data/doc/classes/GSL/Vector.src/{M000005.html → M000015.html} +0 -0
- data/doc/classes/GSL/Vector.src/{M000006.html → M000016.html} +0 -0
- data/doc/classes/Matrix.html +184 -0
- data/doc/classes/Matrix.src/M000004.html +18 -0
- data/doc/classes/Matrix.src/M000005.html +76 -0
- data/doc/classes/Matrix.src/M000006.html +18 -0
- data/doc/classes/Object.html +7 -7
- data/doc/classes/Object.src/{M000001.html → M000007.html} +1 -1
- data/doc/classes/String.html +90 -20
- data/doc/classes/String.src/{M000002.html → M000008.html} +0 -0
- data/doc/classes/String.src/{M000003.html → M000009.html} +0 -0
- data/doc/classes/String.src/{M000004.html → M000010.html} +0 -0
- data/doc/classes/String.src/M000011.html +18 -0
- data/doc/classes/String.src/M000012.html +18 -0
- data/doc/classes/String.src/M000013.html +18 -0
- data/doc/classes/String.src/M000014.html +18 -0
- data/doc/classes/Vector.html +154 -0
- data/doc/classes/Vector.src/M000001.html +22 -0
- data/doc/classes/Vector.src/M000002.html +25 -0
- data/doc/created.rid +1 -1
- data/doc/files/README.html +14 -8
- data/doc/files/lib/classifier/bayes_rb.html +1 -1
- data/doc/files/lib/classifier/{string_extensions_rb.html → extensions/string_rb.html} +5 -5
- data/doc/files/lib/classifier/extensions/vector_rb.html +120 -0
- data/doc/files/lib/classifier/extensions/vector_serialize_rb.html +1 -1
- data/doc/files/lib/classifier/extensions/word_hash_rb.html +1 -1
- data/doc/files/lib/classifier/lsi/content_node_rb.html +2 -2
- data/doc/files/lib/classifier/lsi/summary_rb.html +115 -0
- data/doc/files/lib/classifier/{extensions → lsi}/word_list_rb.html +3 -3
- data/doc/files/lib/classifier/lsi_rb.html +5 -3
- data/doc/files/lib/classifier_rb.html +2 -2
- data/doc/fr_class_index.html +4 -0
- data/doc/fr_file_index.html +4 -2
- data/doc/fr_method_index.html +49 -34
- data/doc/index.html +2 -2
- data/lib/classifier.rb +1 -1
- data/lib/classifier/{string_extensions.rb → extensions/string.rb} +0 -0
- data/lib/classifier/extensions/vector.rb +106 -0
- data/lib/classifier/extensions/vector_serialize.rb +6 -0
- data/lib/classifier/lsi.rb +101 -31
- data/lib/classifier/lsi/content_node.rb +28 -23
- data/lib/classifier/lsi/summary.rb +31 -0
- data/lib/classifier/{extensions → lsi}/word_list.rb +7 -2
- data/test/{string_extensions → extensions}/word_hash_test.rb +0 -0
- data/test/lsi/lsi_test.rb +36 -1
- metadata +68 -41
- data/doc/classes/Classifier/ContentNode.src/M000031.html +0 -21
- data/doc/classes/Classifier/ContentNode.src/M000034.html +0 -41
- data/doc/classes/Classifier/LSI.src/M000011.html +0 -20
- data/doc/classes/Classifier/LSI.src/M000017.html +0 -32
@@ -10,7 +10,7 @@
|
|
10
10
|
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/classifier/
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/classifier/lsi/word_list.rb, line 15</span>
|
14
14
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_word</span>(<span class="ruby-identifier">word</span>)
|
15
15
|
<span class="ruby-identifier">term</span> = <span class="ruby-identifier">word</span>
|
16
16
|
<span class="ruby-ivar">@location_table</span>[<span class="ruby-identifier">term</span>] = <span class="ruby-ivar">@location_table</span>.<span class="ruby-identifier">size</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@location_table</span>[<span class="ruby-identifier">term</span>]
|
@@ -10,7 +10,7 @@
|
|
10
10
|
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/classifier/
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/classifier/lsi/word_list.rb, line 21</span>
|
14
14
|
<span class="ruby-keyword kw">def</span> <span class="ruby-operator">[]</span>(<span class="ruby-identifier">lookup</span>)
|
15
15
|
<span class="ruby-identifier">term</span> = <span class="ruby-identifier">lookup</span>
|
16
16
|
<span class="ruby-ivar">@location_table</span>[<span class="ruby-identifier">term</span>]
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>word_for_index (Classifier::WordList)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/classifier/lsi/word_list.rb, line 26</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">word_for_index</span>(<span class="ruby-identifier">ind</span>)
|
15
|
+
<span class="ruby-ivar">@location_table</span>.<span class="ruby-identifier">invert</span>[<span class="ruby-identifier">ind</span>]
|
16
|
+
<span class="ruby-keyword kw">end</span></pre>
|
17
|
+
</body>
|
18
|
+
</html>
|
@@ -10,7 +10,7 @@
|
|
10
10
|
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/classifier/
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/classifier/lsi/word_list.rb, line 31</span>
|
14
14
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">size</span>
|
15
15
|
<span class="ruby-ivar">@location_table</span>.<span class="ruby-identifier">size</span>
|
16
16
|
<span class="ruby-keyword kw">end</span></pre>
|
data/doc/classes/GSL.html
CHANGED
@@ -87,7 +87,8 @@
|
|
87
87
|
<div id="class-list">
|
88
88
|
<h3 class="section-bar">Classes and Modules</h3>
|
89
89
|
|
90
|
-
Class <a href="GSL/
|
90
|
+
Class <a href="GSL/Matrix.html" class="link">GSL::Matrix</a><br />
|
91
|
+
Class <a href="GSL/Vector.html" class="link">GSL::Vector</a><br />
|
91
92
|
|
92
93
|
</div>
|
93
94
|
|
@@ -0,0 +1,126 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>Class: GSL::Matrix</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="classHeader">
|
50
|
+
<table class="header-table">
|
51
|
+
<tr class="top-aligned-row">
|
52
|
+
<td><strong>Class</strong></td>
|
53
|
+
<td class="class-name-in-header">GSL::Matrix</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../files/lib/classifier/extensions/vector_serialize_rb.html">
|
59
|
+
lib/classifier/extensions/vector_serialize.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
</td>
|
63
|
+
</tr>
|
64
|
+
|
65
|
+
<tr class="top-aligned-row">
|
66
|
+
<td><strong>Parent:</strong></td>
|
67
|
+
<td>
|
68
|
+
<a href="../Object.html">
|
69
|
+
Object
|
70
|
+
</a>
|
71
|
+
</td>
|
72
|
+
</tr>
|
73
|
+
</table>
|
74
|
+
</div>
|
75
|
+
<!-- banner header -->
|
76
|
+
|
77
|
+
<div id="bodyContent">
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
<div id="contextContent">
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
</div>
|
86
|
+
|
87
|
+
|
88
|
+
</div>
|
89
|
+
|
90
|
+
|
91
|
+
<!-- if includes -->
|
92
|
+
|
93
|
+
<div id="section">
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
<div id="aliases-list">
|
98
|
+
<h3 class="section-bar">External Aliases</h3>
|
99
|
+
|
100
|
+
<div class="name-list">
|
101
|
+
<table summary="aliases">
|
102
|
+
<tr class="top-aligned-row context-row">
|
103
|
+
<td class="context-item-name">diagonal</td>
|
104
|
+
<td>-></td>
|
105
|
+
<td class="context-item-value">diag</td>
|
106
|
+
</tr>
|
107
|
+
</table>
|
108
|
+
</div>
|
109
|
+
</div>
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
<!-- if method_list -->
|
116
|
+
|
117
|
+
|
118
|
+
</div>
|
119
|
+
|
120
|
+
|
121
|
+
<div id="validator-badges">
|
122
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
123
|
+
</div>
|
124
|
+
|
125
|
+
</body>
|
126
|
+
</html>
|
data/doc/classes/GSL/Vector.html
CHANGED
@@ -88,8 +88,8 @@
|
|
88
88
|
<h3 class="section-bar">Methods</h3>
|
89
89
|
|
90
90
|
<div class="name-list">
|
91
|
-
<a href="#
|
92
|
-
<a href="#
|
91
|
+
<a href="#M000015">_dump</a>
|
92
|
+
<a href="#M000016">_load</a>
|
93
93
|
</div>
|
94
94
|
</div>
|
95
95
|
|
@@ -111,12 +111,12 @@
|
|
111
111
|
<div id="methods">
|
112
112
|
<h3 class="section-bar">Public Class methods</h3>
|
113
113
|
|
114
|
-
<div id="method-
|
115
|
-
<a name="
|
114
|
+
<div id="method-M000016" class="method-detail">
|
115
|
+
<a name="M000016"></a>
|
116
116
|
|
117
117
|
<div class="method-heading">
|
118
|
-
<a href="Vector.src/
|
119
|
-
onclick="popupCode('Vector.src/
|
118
|
+
<a href="Vector.src/M000016.html" target="Code" class="method-signature"
|
119
|
+
onclick="popupCode('Vector.src/M000016.html');return false;">
|
120
120
|
<span class="method-name">_load</span><span class="method-args">(arr)</span>
|
121
121
|
</a>
|
122
122
|
</div>
|
@@ -127,12 +127,12 @@
|
|
127
127
|
|
128
128
|
<h3 class="section-bar">Public Instance methods</h3>
|
129
129
|
|
130
|
-
<div id="method-
|
131
|
-
<a name="
|
130
|
+
<div id="method-M000015" class="method-detail">
|
131
|
+
<a name="M000015"></a>
|
132
132
|
|
133
133
|
<div class="method-heading">
|
134
|
-
<a href="Vector.src/
|
135
|
-
onclick="popupCode('Vector.src/
|
134
|
+
<a href="Vector.src/M000015.html" target="Code" class="method-signature"
|
135
|
+
onclick="popupCode('Vector.src/M000015.html');return false;">
|
136
136
|
<span class="method-name">_dump</span><span class="method-args">(v)</span>
|
137
137
|
</a>
|
138
138
|
</div>
|
File without changes
|
File without changes
|
@@ -0,0 +1,184 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>Class: Matrix</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="classHeader">
|
50
|
+
<table class="header-table">
|
51
|
+
<tr class="top-aligned-row">
|
52
|
+
<td><strong>Class</strong></td>
|
53
|
+
<td class="class-name-in-header">Matrix</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../files/lib/classifier/extensions/vector_rb.html">
|
59
|
+
lib/classifier/extensions/vector.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
</td>
|
63
|
+
</tr>
|
64
|
+
|
65
|
+
<tr class="top-aligned-row">
|
66
|
+
<td><strong>Parent:</strong></td>
|
67
|
+
<td>
|
68
|
+
<a href="Object.html">
|
69
|
+
Object
|
70
|
+
</a>
|
71
|
+
</td>
|
72
|
+
</tr>
|
73
|
+
</table>
|
74
|
+
</div>
|
75
|
+
<!-- banner header -->
|
76
|
+
|
77
|
+
<div id="bodyContent">
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
<div id="contextContent">
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
</div>
|
86
|
+
|
87
|
+
<div id="method-list">
|
88
|
+
<h3 class="section-bar">Methods</h3>
|
89
|
+
|
90
|
+
<div class="name-list">
|
91
|
+
<a href="#M000005">SV_decomp</a>
|
92
|
+
<a href="#M000006">[]=</a>
|
93
|
+
<a href="#M000004">diag</a>
|
94
|
+
</div>
|
95
|
+
</div>
|
96
|
+
|
97
|
+
</div>
|
98
|
+
|
99
|
+
|
100
|
+
<!-- if includes -->
|
101
|
+
|
102
|
+
<div id="section">
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
<div id="aliases-list">
|
107
|
+
<h3 class="section-bar">External Aliases</h3>
|
108
|
+
|
109
|
+
<div class="name-list">
|
110
|
+
<table summary="aliases">
|
111
|
+
<tr class="top-aligned-row context-row">
|
112
|
+
<td class="context-item-name">transpose</td>
|
113
|
+
<td>-></td>
|
114
|
+
<td class="context-item-value">trans</td>
|
115
|
+
</tr>
|
116
|
+
</table>
|
117
|
+
</div>
|
118
|
+
</div>
|
119
|
+
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
<!-- if method_list -->
|
125
|
+
<div id="methods">
|
126
|
+
<h3 class="section-bar">Public Class methods</h3>
|
127
|
+
|
128
|
+
<div id="method-M000004" class="method-detail">
|
129
|
+
<a name="M000004"></a>
|
130
|
+
|
131
|
+
<div class="method-heading">
|
132
|
+
<a href="Matrix.src/M000004.html" target="Code" class="method-signature"
|
133
|
+
onclick="popupCode('Matrix.src/M000004.html');return false;">
|
134
|
+
<span class="method-name">diag</span><span class="method-args">(s)</span>
|
135
|
+
</a>
|
136
|
+
</div>
|
137
|
+
|
138
|
+
<div class="method-description">
|
139
|
+
</div>
|
140
|
+
</div>
|
141
|
+
|
142
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
143
|
+
|
144
|
+
<div id="method-M000005" class="method-detail">
|
145
|
+
<a name="M000005"></a>
|
146
|
+
|
147
|
+
<div class="method-heading">
|
148
|
+
<a href="Matrix.src/M000005.html" target="Code" class="method-signature"
|
149
|
+
onclick="popupCode('Matrix.src/M000005.html');return false;">
|
150
|
+
<span class="method-name">SV_decomp</span><span class="method-args">(maxSweeps = 20)</span>
|
151
|
+
</a>
|
152
|
+
</div>
|
153
|
+
|
154
|
+
<div class="method-description">
|
155
|
+
</div>
|
156
|
+
</div>
|
157
|
+
|
158
|
+
<div id="method-M000006" class="method-detail">
|
159
|
+
<a name="M000006"></a>
|
160
|
+
|
161
|
+
<div class="method-heading">
|
162
|
+
<a href="Matrix.src/M000006.html" target="Code" class="method-signature"
|
163
|
+
onclick="popupCode('Matrix.src/M000006.html');return false;">
|
164
|
+
<span class="method-name">[]=</span><span class="method-args">(i,j,val)</span>
|
165
|
+
</a>
|
166
|
+
</div>
|
167
|
+
|
168
|
+
<div class="method-description">
|
169
|
+
</div>
|
170
|
+
</div>
|
171
|
+
|
172
|
+
|
173
|
+
</div>
|
174
|
+
|
175
|
+
|
176
|
+
</div>
|
177
|
+
|
178
|
+
|
179
|
+
<div id="validator-badges">
|
180
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
181
|
+
</div>
|
182
|
+
|
183
|
+
</body>
|
184
|
+
</html>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>diag (Matrix)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/classifier/extensions/vector.rb, line 36</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-constant">Matrix</span>.<span class="ruby-identifier">diag</span>(<span class="ruby-identifier">s</span>)
|
15
|
+
<span class="ruby-constant">Matrix</span>.<span class="ruby-identifier">diagonal</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">s</span>)
|
16
|
+
<span class="ruby-keyword kw">end</span></pre>
|
17
|
+
</body>
|
18
|
+
</html>
|
@@ -0,0 +1,76 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>SV_decomp (Matrix)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/classifier/extensions/vector.rb, line 42</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-constant">SV_decomp</span>(<span class="ruby-identifier">maxSweeps</span> = <span class="ruby-value">20</span>)
|
15
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">row_size</span> <span class="ruby-operator">>=</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">column_size</span>
|
16
|
+
<span class="ruby-identifier">q</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">trans</span> <span class="ruby-operator">*</span> <span class="ruby-keyword kw">self</span>
|
17
|
+
<span class="ruby-keyword kw">else</span>
|
18
|
+
<span class="ruby-identifier">q</span> = <span class="ruby-keyword kw">self</span> <span class="ruby-operator">*</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">trans</span>
|
19
|
+
<span class="ruby-keyword kw">end</span>
|
20
|
+
|
21
|
+
<span class="ruby-identifier">qrot</span> = <span class="ruby-identifier">q</span>.<span class="ruby-identifier">dup</span>
|
22
|
+
<span class="ruby-identifier">v</span> = <span class="ruby-constant">Matrix</span>.<span class="ruby-identifier">identity</span>(<span class="ruby-identifier">q</span>.<span class="ruby-identifier">row_size</span>)
|
23
|
+
<span class="ruby-identifier">azrot</span> = <span class="ruby-keyword kw">nil</span>
|
24
|
+
<span class="ruby-identifier">mzrot</span> = <span class="ruby-keyword kw">nil</span>
|
25
|
+
<span class="ruby-identifier">cnt</span> = <span class="ruby-value">0</span>
|
26
|
+
<span class="ruby-identifier">s_old</span> = <span class="ruby-keyword kw">nil</span>
|
27
|
+
<span class="ruby-identifier">mu</span> = <span class="ruby-keyword kw">nil</span>
|
28
|
+
|
29
|
+
<span class="ruby-keyword kw">while</span> <span class="ruby-keyword kw">true</span> <span class="ruby-keyword kw">do</span>
|
30
|
+
<span class="ruby-identifier">cnt</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
|
31
|
+
<span class="ruby-keyword kw">for</span> <span class="ruby-identifier">row</span> <span class="ruby-keyword kw">in</span> (<span class="ruby-value">0</span><span class="ruby-operator">...</span><span class="ruby-identifier">qrot</span>.<span class="ruby-identifier">row_size</span><span class="ruby-operator">-</span><span class="ruby-value">1</span>) <span class="ruby-keyword kw">do</span>
|
32
|
+
<span class="ruby-keyword kw">for</span> <span class="ruby-identifier">col</span> <span class="ruby-keyword kw">in</span> (<span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-identifier">qrot</span>.<span class="ruby-identifier">row_size</span><span class="ruby-operator">-</span><span class="ruby-value">1</span>) <span class="ruby-keyword kw">do</span>
|
33
|
+
<span class="ruby-keyword kw">next</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">row</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">col</span>
|
34
|
+
<span class="ruby-identifier">h</span> = <span class="ruby-constant">Math</span>.<span class="ruby-identifier">atan</span>((<span class="ruby-value">2</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">qrot</span>[<span class="ruby-identifier">row</span>,<span class="ruby-identifier">col</span>])<span class="ruby-operator">/</span>(<span class="ruby-identifier">qrot</span>[<span class="ruby-identifier">row</span>,<span class="ruby-identifier">row</span>]<span class="ruby-operator">-</span><span class="ruby-identifier">qrot</span>[<span class="ruby-identifier">col</span>,<span class="ruby-identifier">col</span>]))<span class="ruby-operator">/</span><span class="ruby-value">2.0</span>
|
35
|
+
<span class="ruby-identifier">hcos</span> = <span class="ruby-constant">Math</span>.<span class="ruby-identifier">cos</span>(<span class="ruby-identifier">h</span>)
|
36
|
+
<span class="ruby-identifier">hsin</span> = <span class="ruby-constant">Math</span>.<span class="ruby-identifier">sin</span>(<span class="ruby-identifier">h</span>)
|
37
|
+
<span class="ruby-identifier">mzrot</span> = <span class="ruby-constant">Matrix</span>.<span class="ruby-identifier">identity</span>(<span class="ruby-identifier">qrot</span>.<span class="ruby-identifier">row_size</span>)
|
38
|
+
<span class="ruby-identifier">mzrot</span>[<span class="ruby-identifier">row</span>,<span class="ruby-identifier">row</span>] = <span class="ruby-identifier">hcos</span>
|
39
|
+
<span class="ruby-identifier">mzrot</span>[<span class="ruby-identifier">row</span>,<span class="ruby-identifier">col</span>] = <span class="ruby-operator">-</span><span class="ruby-identifier">hsin</span>
|
40
|
+
<span class="ruby-identifier">mzrot</span>[<span class="ruby-identifier">col</span>,<span class="ruby-identifier">row</span>] = <span class="ruby-identifier">hsin</span>
|
41
|
+
<span class="ruby-identifier">mzrot</span>[<span class="ruby-identifier">col</span>,<span class="ruby-identifier">col</span>] = <span class="ruby-identifier">hcos</span>
|
42
|
+
<span class="ruby-identifier">qrot</span> = <span class="ruby-identifier">mzrot</span>.<span class="ruby-identifier">trans</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">qrot</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">mzrot</span>
|
43
|
+
<span class="ruby-identifier">v</span> = <span class="ruby-identifier">v</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">mzrot</span>
|
44
|
+
<span class="ruby-keyword kw">end</span>
|
45
|
+
<span class="ruby-keyword kw">end</span>
|
46
|
+
<span class="ruby-identifier">s_old</span> = <span class="ruby-identifier">qrot</span>.<span class="ruby-identifier">dup</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">cnt</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span>
|
47
|
+
<span class="ruby-identifier">sum_qrot</span> = <span class="ruby-value">0</span><span class="ruby-value">.0</span>
|
48
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">cnt</span> <span class="ruby-operator">></span> <span class="ruby-value">1</span>
|
49
|
+
<span class="ruby-identifier">qrot</span>.<span class="ruby-identifier">row_size</span>.<span class="ruby-identifier">times</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">r</span><span class="ruby-operator">|</span>
|
50
|
+
<span class="ruby-identifier">sum_qrot</span> <span class="ruby-operator">+=</span> (<span class="ruby-identifier">qrot</span>[<span class="ruby-identifier">r</span>,<span class="ruby-identifier">r</span>]<span class="ruby-operator">-</span><span class="ruby-identifier">s_old</span>[<span class="ruby-identifier">r</span>,<span class="ruby-identifier">r</span>]).<span class="ruby-identifier">abs</span> <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">qrot</span>[<span class="ruby-identifier">r</span>,<span class="ruby-identifier">r</span>]<span class="ruby-operator">-</span><span class="ruby-identifier">s_old</span>[<span class="ruby-identifier">r</span>,<span class="ruby-identifier">r</span>]).<span class="ruby-identifier">abs</span> <span class="ruby-operator">></span> <span class="ruby-value">0</span><span class="ruby-value">.001</span>
|
51
|
+
<span class="ruby-keyword kw">end</span>
|
52
|
+
<span class="ruby-identifier">s_old</span> = <span class="ruby-identifier">qrot</span>.<span class="ruby-identifier">dup</span>
|
53
|
+
<span class="ruby-keyword kw">end</span>
|
54
|
+
<span class="ruby-keyword kw">break</span> <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">sum_qrot</span> <span class="ruby-operator"><=</span> <span class="ruby-value">0</span><span class="ruby-value">.001</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">cnt</span> <span class="ruby-operator">></span> <span class="ruby-value">1</span>) <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">cnt</span> <span class="ruby-operator">>=</span> <span class="ruby-identifier">maxSweeps</span>
|
55
|
+
<span class="ruby-keyword kw">end</span> <span class="ruby-comment cmt"># of do while true</span>
|
56
|
+
<span class="ruby-identifier">s</span> = []
|
57
|
+
<span class="ruby-identifier">qrot</span>.<span class="ruby-identifier">row_size</span>.<span class="ruby-identifier">times</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">r</span><span class="ruby-operator">|</span>
|
58
|
+
<span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-constant">Math</span>.<span class="ruby-identifier">sqrt</span>(<span class="ruby-identifier">qrot</span>[<span class="ruby-identifier">r</span>,<span class="ruby-identifier">r</span>])
|
59
|
+
<span class="ruby-keyword kw">end</span>
|
60
|
+
<span class="ruby-comment cmt">#puts "cnt = #{cnt}"</span>
|
61
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">row_size</span> <span class="ruby-operator">>=</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">column_size</span>
|
62
|
+
<span class="ruby-identifier">mu</span> = <span class="ruby-keyword kw">self</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">v</span> <span class="ruby-operator">*</span> <span class="ruby-constant">Matrix</span>.<span class="ruby-identifier">diagonal</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">s</span>).<span class="ruby-identifier">inverse</span>
|
63
|
+
<span class="ruby-keyword kw">return</span> [<span class="ruby-identifier">mu</span>, <span class="ruby-identifier">v</span>, <span class="ruby-identifier">s</span>]
|
64
|
+
<span class="ruby-keyword kw">else</span>
|
65
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-identifier">v</span>.<span class="ruby-identifier">row_size</span>
|
66
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-identifier">v</span>.<span class="ruby-identifier">column_size</span>
|
67
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">row_size</span>
|
68
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">column_size</span>
|
69
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-identifier">s</span>.<span class="ruby-identifier">size</span>
|
70
|
+
|
71
|
+
<span class="ruby-identifier">mu</span> = (<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">trans</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">v</span> <span class="ruby-operator">*</span> <span class="ruby-constant">Matrix</span>.<span class="ruby-identifier">diagonal</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">s</span>).<span class="ruby-identifier">inverse</span>)
|
72
|
+
<span class="ruby-keyword kw">return</span> [<span class="ruby-identifier">mu</span>, <span class="ruby-identifier">v</span>, <span class="ruby-identifier">s</span>]
|
73
|
+
<span class="ruby-keyword kw">end</span>
|
74
|
+
<span class="ruby-keyword kw">end</span></pre>
|
75
|
+
</body>
|
76
|
+
</html>
|