This file is indexed.

/usr/share/psi4/plugin/ambit/convert.cc.template is in psi4-data 1:1.1-5.

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
/*
 * @BEGIN LICENSE
 *
 * Psi4: an open-source quantum chemistry software package
 *
 * Copyright (c) 2007-2017 The Psi4 Developers.
 *
 * The copyrights for code used from other parties are included in
 * the corresponding files.
 *
 * This file is part of Psi4.
 *
 * Psi4 is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, version 3.
 *
 * Psi4 is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License along
 * with Psi4; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * @END LICENSE
 */

//
// Created by Justin Turney on 1/5/16.
//

#include "convert.h"
#include <ambit/tensor.h>
//#include <tensor/core/core.h>

namespace ambit
{

namespace helpers
{

namespace psi4
{

void convert(const psi::Matrix &matrix, ambit::Tensor *target)
{
    if (target->rank() != 2)
        throw std::runtime_error(
            "convert(psi::Matrix, ambit::Tensor): Tensor is not rank 2");

    if (matrix.nirrep() != 1)
        throw std::runtime_error("convert(psi::Matrix, ambit::Tensor): Matrix "
                                 "appears to have symmetry (nirrep != 1)");

    if (matrix.rowdim() != target->dim(0))
        throw std::runtime_error("convert(psi::Matrix, ambit::Tensor): Matrix "
                                 "and Tensor do not have the same number of "
                                 "rows (dim(0))");
    if (matrix.coldim() != target->dim(1))
        throw std::runtime_error("convert(psi::Matrix, ambit::Tensor): Matrix "
                                 "and Tensor do not have the same number of "
                                 "columns (dim(1))");

    size_t row = target->dim(0);
    size_t col = target->dim(1);

    Tensor local_tensor = Tensor::build(CoreTensor, "Local Data", {row, col});

    if (row && col) {
        // copy data from SharedMatrix to local_tensor
        std::copy(matrix.pointer()[0], matrix.pointer()[0] + (row * col),
                  local_tensor.data().begin());
    }

    // Splice data into the target tensor
    (*target)() = local_tensor();
}

void convert(const psi::Vector &vector, ambit::Tensor *target)
{
    if (target->rank() != 1)
        throw std::runtime_error(
            "convert(psi::Matrix, ambit::Tensor): Tensor is not rank 1");

    if (vector.nirrep() != 1)
        throw std::runtime_error("convert(psi::Matrix, ambit::Tensor): Matrix "
                                 "appears to have symmetry (nirrep != 1)");

    if (vector.dim() != target->dim(0))
        throw std::runtime_error("convert(psi::Matrix, ambit::Tensor): Matrix "
                                 "and Tensor do not have the same number of "
                                 "elements (dim(0))");

    size_t row = target->dim(0);

    Tensor local_tensor = Tensor::build(CoreTensor, "Local Data", {row});

    // copy data from SharedMatrix to local_tensor
    std::copy(vector.pointer(), vector.pointer() + (row),
              local_tensor.data().begin());

    // Splice data into the target tensor
    (*target)() = local_tensor();
}

} // namespace psi4

} // namespace helpers

} // namespace ambit