Esempio n. 1
0
        public void add(sMatrix m)
        {
            if (_r != m.R || _c != m.C)
            {
                throw new Exception("error");
            }

            for (int r = 0; r < _r; r++)
            {
                for (int c = 0; c < _c; c++)
                {
                    this[r, c] += m[r, c];
                }
            }
        }
Esempio n. 2
0
        public static void summarize(string fn = "f2")
        {
            StreamReader sr  = new StreamReader(Global.outDir + Global.fResRaw);
            string       txt = sr.ReadToEnd();

            sr.Close();
            txt = txt.Replace("\r", "");
            string[]     regions = txt.Split(Global.triLineEndAry, StringSplitOptions.RemoveEmptyEntries);
            StreamWriter sw      = new StreamWriter(Global.outDir + Global.fResSum);

            foreach (string region in regions)
            {
                string[]       blocks = region.Split(Global.biLineEndAry, StringSplitOptions.RemoveEmptyEntries);
                List <dMatrix> mList  = new List <dMatrix>();
                foreach (string im in blocks)
                {
                    dMatrix m = new dMatrix(im);
                    mList.Add(m);
                }

                //get average
                dMatrix avgM = new dMatrix(mList[0]);
                avgM.set(0);
                foreach (dMatrix m in mList)
                {
                    avgM.add(m);
                }
                avgM.divide(mList.Count);
                //get devi
                dMatrix deviM = mathTool.getDeviation(mList);

                sw.WriteLine("%averaged values:");
                avgM.write(sw, fn);
                sw.WriteLine();
                sw.WriteLine("%deviations:");
                deviM.write(sw, fn);
                sw.WriteLine();
                sw.WriteLine("%avg & devi:");

                sMatrix sAvgM = new sMatrix(avgM, fn);
                sAvgM.add("+-");
                sMatrix sDeviM = new sMatrix(deviM, fn);
                sAvgM.add(sDeviM);
                sAvgM.write(sw);
                sw.WriteLine("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n");
            }
            sw.Close();
        }