about summary refs log tree commit diff
path: root/sourcecodes/bnt-master/KPMtools/partition_matrix_vec.m
diff options
context:
space:
mode:
authorziejd22018-03-14 23:23:33 -0500
committerGitHub2018-03-14 23:23:33 -0500
commit1ff6baa44e22b91eefb48aea6f3befa078c0489b (patch)
treee0fd79d2e32fd2aedda2eadaed0f19af3514c520 /sourcecodes/bnt-master/KPMtools/partition_matrix_vec.m
parent6882395afdadf4e982b25b5215071a0932730950 (diff)
parentc80226899f5cdd9f11c163817d59445213f5bef0 (diff)
downloadBNW-1ff6baa44e22b91eefb48aea6f3befa078c0489b.tar.gz
Merge pull request #1 from ziejd2/octave_php_separate
Octave php separate
Diffstat (limited to 'sourcecodes/bnt-master/KPMtools/partition_matrix_vec.m')
-rw-r--r--sourcecodes/bnt-master/KPMtools/partition_matrix_vec.m21
1 files changed, 21 insertions, 0 deletions
diff --git a/sourcecodes/bnt-master/KPMtools/partition_matrix_vec.m b/sourcecodes/bnt-master/KPMtools/partition_matrix_vec.m
new file mode 100644
index 00000000..6ac456c5
--- /dev/null
+++ b/sourcecodes/bnt-master/KPMtools/partition_matrix_vec.m
@@ -0,0 +1,21 @@
+function [m1, m2, K11, K12, K21, K22] = partition_matrix_vec(m, K, n1, n2, bs)
+% PARTITION_MATRIX_VEC Partition a vector and matrix into blocks.
+% [m1, m2, K11, K12, K21, K22] = partition_matrix_vec(m, K, blocks1, blocks2, bs)
+%
+% bs(i) = block size of i'th node
+%
+% Example:
+% n1 = [6 8], n2 = [5], bs = [- - - - 2 1 - 2], where - = don't care
+% m = [0.1 0.2   0.3   0.4 0.5], K = some 5*5 matrix,
+% So E[X5] = [0.1 0.2], E[X6] = [0.3], E[X8] = [0.4 0.5]
+% m1 = [0.3 0.4 0.5], m2 = [0.1 0.2];
+
+dom = myunion(n1, n2);
+n1i = block(find_equiv_posns(n1, dom), bs(dom));
+n2i = block(find_equiv_posns(n2, dom), bs(dom));
+m1 = m(n1i);
+m2 = m(n2i);
+K11 = K(n1i, n1i);
+K12 = K(n1i, n2i);
+K21 = K(n2i, n1i);
+K22 = K(n2i, n2i);