Vector decode_col_vector()

in src/hit/api/linearalgebra/encryptedcolvector.cpp [208:228]


    Vector decode_col_vector(const vector<Matrix> &mats, int trim_length) {
        if (mats.empty()) {
            LOG_AND_THROW_STREAM("Internal error: input to decode_col_vector cannot be empty");
        }

        if (trim_length < 0) {
            trim_length = static_cast<int>(mats.size() * mats[0].size2());
        }

        // col vectors are encoded as rows of a matrix.
        // return the first row of each matrix, concatenated together
        vector<double> v;
        v.reserve(trim_length);
        for (int i = 0; i < mats.size(); i++) {
            for (int j = 0; j < mats[0].size2() && i * mats[0].size2() + j < trim_length; j++) {
                v.emplace_back(mats[i](0, j));
            }
        }

        return Vector(v);
    }