/usr/lib/petscdir/3.7.7/x86_64-linux-gnu-real-debug/share/petsc/saws/js/matrixTex.js is in libpetsc3.7.7-dbg 3.7.7+dfsg1-2build5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | //gives users a visual of the nested matricies
//instead of using subscript of subscript of subscript, etc. simply put the id of the matrix in the first subscript level. for example, A_{010}
//this function is recursive and should always be called with parameter "0"
//weird because the longer the string is, the more deep the recursion is. "0" is the top level. digits are only added. never removed
function getMatrixTex(data, endtag) {
if(data[endtag] == undefined)
return;
//case 1: not logstruc. base case.
if(!data[endtag].logstruc) {
//return the appropriate tex
var depth = getNumUnderscores(endtag);
var color = colors[depth%colors.length];
var subscript = endtag.replace(/_/g, ",");
return "{\\color{"+color+"}" + "\\left[A_{" + subscript + "}" + "\\right]}";
}
//case 2: has more children. recursive case.
else {
var depth = getNumUnderscores(endtag);
var color = colors[depth%colors.length];
var ret = "";
var blocks = data[endtag].pc_fieldsplit_blocks;
var childrenTex = "";
var justify = "";
for(var i=0; i<blocks-1; i++) {
justify += "c@{}";
}
justify += "c";
ret += "\\color{"+color+"}" + "\\left[" + "\\color{black}" + "\\begin{array}{"+justify+"}";//begin the matrix
for(var i=0; i<blocks; i++) {//NEED TO ADD STARS
for(var j=0; j<i; j++) {//add the stars that go BEFORE the diagonal element
ret += "* & ";
}
var childEndtag = endtag + "_" + i;
//lay out chilren
var childTex = getMatrixTex(data, childEndtag);
if(childTex != "")
ret += getMatrixTex(data, childEndtag);
else {
var subscript = childEndtag.replace(/_/g, ",");
ret += "A_{" + subscript + "}";
}
for(var j=i+1; j<blocks; j++) {//add the stars that go AFTER the diagonal element
ret += "& *";
}
ret += "\\\\"; //add the backslash indicating the next matrix row
}
ret += "\\end{array}\\right]";//close the matrix
return ret;
}
}
var bjacobiSplits = [];//global variable that keeps track of how the bjacobi blocks were split
//this function displays a visual of the nested pc=bjacobi block structure and/or nested pc=ksp block structure
//this function is recursive and should almost always be called with parameter "0" like so: getSpecificMatrixTex("0")
function getSpecificMatrixTex(data, endtag) {
if(endtag == "0") {//reset bjacobi splits data
delete bjacobiSplits;
bjacobiSplits.length=0;
}
var ret = "";//returned value
if(data[endtag] == undefined) //invalid matrix
return ret;
var pc = data[endtag].pc_type;
var ksp = data[endtag].ksp_type;
//case 1: non-recursive base case
if(pc != "ksp" && pc != "bjacobi") {
return ksp+"/"+pc;//don't put braces at the very end
}
//case 2: pc=ksp recursive case
if(pc == "ksp") {
ret += "\\left.\\begin{aligned}";
endtag += "_0";
//ksp is a composite pc so there will be more options
ret += getSpecificMatrixTex(endtag);
ret += "\\end{aligned}\\right\\}"+ksp+"/"+pc;
return ret;
}
//case 3: pc=bjacobi recursive case
else if(pc == "bjacobi") {
ret += "\\left.\\begin{aligned}";
endtag += "_0";
var blocks = data[endtag].pc_bjacobi_blocks;
//record that we split
var idx = bjacobiSplits.length;
bjacobiSplits[idx] = blocks;
var childTex = getSpecificMatrixTex(endtag);
for(var i=0; i<blocks; i++)
ret += childTex + "\\\\";
ret += "\\end{aligned}\\right\\}" + ksp+"/"+pc;
return ret;
}
return ret;
}
//this function generates the corresponding matrix for the specific matrix diagram
//this function is recursive and should always be called with parameter 0 like so: getSpecificMatrixTex2(0)
function getSpecificMatrixTex2(index) {
//case 1: matrix was not split
if(bjacobiSplits.length == 0) {
return "\\left[ \\begin{array}{c} * \\end{array}\\right]";
}
//case 2: base case
else if(index >= bjacobiSplits.length) {
return "\\left[ \\begin{array}{c} * \\end{array}\\right]";
}
//case 3: recursive case
else {
var ret = "";
var blocks = bjacobiSplits[index];
var innerTex = "";
var justify = "";
for(var i=0; i<blocks-1; i++) {
justify += "c@{}";
}
justify += "c";
ret += "\\left[ \\begin{array}{"+justify+"}";//begin the matrix
innerTex = getSpecificMatrixTex2(index+1);
for(var i=0; i<blocks; i++) {//iterate thru entire square matrix row by row
for(var j=0; j<i; j++) {//add the stars that go BEFORE the diagonal element
ret += "* & ";
}
ret += innerTex;
for(var j=i+1; j<blocks; j++) {//add the stars that go AFTER the diagonal element
ret += "& *";
}
ret += "\\\\"; //add the backslash indicating the next matrix row
}
ret += "\\end{array}\\right]";//close the matrix
return ret;
}
}
|