<commit_before>#include <gtest/gtest.h>
#include <limits>
#include <stan/math/rev/mat.hpp>
#include <string>
#include <vector>

TEST(MathPrimMat, var_mat_double_add_diag) {
  Eigen::Matrix<stan::math::var, Eigen::Dynamic, Eigen::Dynamic> mat(2, 3);
  mat << 1, 1, 1, 1, 1, 1;

  double jitter = 1e-10;

  Eigen::Matrix<stan::math::var, Eigen::Dynamic, Eigen::Dynamic> out_mat;
  EXPECT_NO_THROW(out_mat = stan::math::add_diag(mat, jitter));
  for (int i = 0; i < 2; ++i) {
    for (int j = 0; j < 3; ++j) {
      if (i == j)
        EXPECT_FLOAT_EQ(1.0 + jitter, value_of(out_mat(i, j)))
            << "index: ( " << i << ", " << i << ")";
      else
        EXPECT_FLOAT_EQ(1, value_of(out_mat(i, j)))
            << "index: ( " << i << ", " << i << ")";
    }
  }
}<commit_msg>Update add_diag_test.cpp<commit_after>#include <gtest/gtest.h>
#include <stan/math/rev/mat.hpp>
#include <limits>
#include <string>
#include <vector>

TEST(MathPrimMat, var_mat_double_add_diag) {
  Eigen::Matrix<stan::math::var, Eigen::Dynamic, Eigen::Dynamic> mat(2, 3);
  mat << 1, 1, 1, 1, 1, 1;

  double jitter = 1e-10;

  Eigen::Matrix<stan::math::var, Eigen::Dynamic, Eigen::Dynamic> out_mat;
  EXPECT_NO_THROW(out_mat = stan::math::add_diag(mat, jitter));
  for (int i = 0; i < 2; ++i) {
    for (int j = 0; j < 3; ++j) {
      if (i == j)
        EXPECT_FLOAT_EQ(1.0 + jitter, value_of(out_mat(i, j)))
            << "index: ( " << i << ", " << i << ")";
      else
        EXPECT_FLOAT_EQ(1, value_of(out_mat(i, j)))
            << "index: ( " << i << ", " << i << ")";
    }
  }
}
{'fraction_non_alphanumeric': 0.2145130490133673, 'fraction_numerical': 0.022915340547422024, 'mean_word_length': 3.2371967654986524, 'pattern_counts': {'":': 0, '<': 65, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4901030', 'n_tokens_mistral': 672, 'n_tokens_neox': 640, 'n_words': 131}