| 1 | /* |
| 2 | * MatrixEntryColumn.java |
| 3 | * |
| 4 | * Copyright (c) 2002-2015 Alexei Drummond, Andrew Rambaut and Marc Suchard |
| 5 | * |
| 6 | * This file is part of BEAST. |
| 7 | * See the NOTICE file distributed with this work for additional |
| 8 | * information regarding copyright ownership and licensing. |
| 9 | * |
| 10 | * BEAST is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU Lesser General Public License as |
| 12 | * published by the Free Software Foundation; either version 2 |
| 13 | * of the License, or (at your option) any later version. |
| 14 | * |
| 15 | * BEAST is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | * GNU Lesser General Public License for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU Lesser General Public |
| 21 | * License along with BEAST; if not, write to the |
| 22 | * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, |
| 23 | * Boston, MA 02110-1301 USA |
| 24 | */ |
| 25 | |
| 26 | package dr.inference.loggers; |
| 27 | |
| 28 | /** |
| 29 | * @author Marc A. Suchard |
| 30 | */ |
| 31 | public class MatrixEntryColumn extends NumberColumn { |
| 32 | |
| 33 | private int indexI; |
| 34 | private int indexJ; |
| 35 | private double[][] mat; |
| 36 | private Double normalization; |
| 37 | |
| 38 | public MatrixEntryColumn(String name, int indexI, int indexJ, double[][] mat, Double normalization) { |
| 39 | super(name + "_" + indexI + "/" + indexJ); |
| 40 | |
| 41 | this.mat = mat; |
| 42 | |
| 43 | if (indexI < 0 || indexJ < 0 || indexI >= mat.length || indexJ >= mat[0].length) |
| 44 | throw new RuntimeException("Out of bounds"); |
| 45 | |
| 46 | this.indexI = indexI; |
| 47 | this.indexJ = indexJ; |
| 48 | this.normalization = normalization; |
| 49 | } |
| 50 | |
| 51 | public MatrixEntryColumn(String name, int indexI, int indexJ, double[][] mat) { |
| 52 | this(name, indexI, indexJ, mat, 1.0); |
| 53 | } |
| 54 | |
| 55 | public double getDoubleValue() { |
| 56 | return mat[indexI][indexJ] / normalization; |
| 57 | } |
| 58 | } |