/** @brief Compute the norm of a dual vector (specified by coefficients in the dual basis). @param A input lattice @param b coefficients of shortest dual vector @return */ template <class ZT> int dual_length(Float &norm, ZZ_mat<ZT> &A, const IntVect &coords) { int d = coords.size(); if (A.get_rows() != d) { cerr << "DSVP length error: Coefficient vector has wrong dimension: "; cerr << A.get_rows() << " vs " << d << endl; return 1; } FloatVect coords_d(d); for (int i = 0; i < d; i++) { coords_d[i] = coords[i].get_d(); } IntMatrix empty_mat; MatGSO<Integer, Float> gso(A, empty_mat, empty_mat, GSO_INT_GRAM); if (!gso.update_gso()) { cerr << "GSO Failure." << endl; return 1; } Float tmp; gso.get_r(tmp, d - 1, d - 1); tmp.pow_si(tmp, -1); FloatVect alpha(d); Float mu, alpha2, r_inv; norm = 0.0; for (int i = 0; i < d; i++) { alpha[i] = coords_d[i]; for (int j = 0; j < i; j++) { gso.get_mu(mu, i, j); alpha[i] -= mu * alpha[j]; } gso.get_r(r_inv, i, i); r_inv.pow_si(r_inv, -1); alpha2.pow_si(alpha[i], 2); norm += alpha2 * r_inv; } return 0; }