<commit_before>#include <vcl_cstdio.h>
#include <vnl/vnl_math.h> // vnl_math_abs()
#include <testlib/testlib_test.h>

extern "C"
int sggsvd_(char const *jobu, char const *jobv, char const *jobq, int *m, int *n, int *p,
            int *k, int *l, float *a, int *lda, float *b, int *ldb,
            float *alpha, float *beta, float *u, int *ldu, float *v,
            int *ldv, float *q, int *ldq, float *work, int *iwork,
            int *info);

static
void test_qsvd() {
  float AA[9]={2.f/3, -1.36f/3, .2f/3,   2.8f/3, .4f/3, 1.f/3,   1, .16f, -.2f};
  float BB[9]={.16f, -.224f, -.768f,  .8f, .36f, -.48f,  1.12f, -.168f, -.576f};
  float U[9], V[9], Q[9], Alpha[3], Beta[3], Work[12];
  int m=3, n=3, p=3, k, l, Iwork[3], info;

  vcl_printf("m = 3, n = 3, p = 3\n");
  sggsvd_("U", "V", "Q", &m, &n, &p, &k, &l, AA, &n, BB, &n, Alpha, Beta,
          U, &n, V, &n, Q, &n, Work, Iwork, &info);

  vcl_printf("k = %d, l = %d, return = %d\n", k, l, info);
  testlib_test_assert("(k,l) must be (0,3)", k==0 && l==3);
  testlib_test_assert("sggsvd should return 0", info==0);

  vcl_printf("U = %12.7f %12.7f %12.7f\n    %12.7f %12.7f %12.7f\n    %12.7f %12.7f %12.7f\n",
             U[0], U[3], U[6], U[1], U[4], U[7], U[2], U[5], U[8]);
  vcl_printf("V = %12.7f %12.7f %12.7f\n    %12.7f %12.7f %12.7f\n    %12.7f %12.7f %12.7f\n",
             V[0], V[3], V[6], V[1], V[4], V[7], V[2], V[5], V[8]);
  vcl_printf("Q = %12.7f %12.7f %12.7f\n    %12.7f %12.7f %12.7f\n    %12.7f %12.7f %12.7f\n",
             Q[0], Q[3], Q[6], Q[1], Q[4], Q[7], Q[2], Q[5], Q[8]);
  vcl_printf("D1 = diag(%12g %12g %12g)\n", Alpha[0], Alpha[1], Alpha[2]);
  vcl_printf("D2 = diag(%12g %12g %12g)\n", Beta[0], Beta[1], Beta[2]);<commit_msg>COMP: Supply default seed; temporary fix<commit_after>#include <vcl_cstdio.h>
#include <vnl/vnl_math.h> // vnl_math_abs()
#include <testlib/testlib_test.h>
#include <vnl/vnl_sample.h>

extern "C"
int sggsvd_(char const *jobu, char const *jobv, char const *jobq, int *m, int *n, int *p,
            int *k, int *l, float *a, int *lda, float *b, int *ldb,
            float *alpha, float *beta, float *u, int *ldu, float *v,
            int *ldv, float *q, int *ldq, float *work, int *iwork,
            int *info);

static
void test_qsvd() {

  vnl_sample_reseed(0x1234abcd);

  float AA[9]={2.f/3, -1.36f/3, .2f/3,   2.8f/3, .4f/3, 1.f/3,   1, .16f, -.2f};
  float BB[9]={.16f, -.224f, -.768f,  .8f, .36f, -.48f,  1.12f, -.168f, -.576f};
  float U[9], V[9], Q[9], Alpha[3], Beta[3], Work[12];
  int m=3, n=3, p=3, k, l, Iwork[3], info;

  vcl_printf("m = 3, n = 3, p = 3\n");
  sggsvd_("U", "V", "Q", &m, &n, &p, &k, &l, AA, &n, BB, &n, Alpha, Beta,
          U, &n, V, &n, Q, &n, Work, Iwork, &info);

  vcl_printf("k = %d, l = %d, return = %d\n", k, l, info);
  testlib_test_assert("(k,l) must be (0,3)", k==0 && l==3);
  testlib_test_assert("sggsvd should return 0", info==0);

  vcl_printf("U = %12.7f %12.7f %12.7f\n    %12.7f %12.7f %12.7f\n    %12.7f %12.7f %12.7f\n",
             U[0], U[3], U[6], U[1], U[4], U[7], U[2], U[5], U[8]);
  vcl_printf("V = %12.7f %12.7f %12.7f\n    %12.7f %12.7f %12.7f\n    %12.7f %12.7f %12.7f\n",
             V[0], V[3], V[6], V[1], V[4], V[7], V[2], V[5], V[8]);
  vcl_printf("Q = %12.7f %12.7f %12.7f\n    %12.7f %12.7f %12.7f\n    %12.7f %12.7f %12.7f\n",
             Q[0], Q[3], Q[6], Q[1], Q[4], Q[7], Q[2], Q[5], Q[8]);
  vcl_printf("D1 = diag(%12g %12g %12g)\n", Alpha[0], Alpha[1], Alpha[2]);
  vcl_printf("D2 = diag(%12g %12g %12g)\n", Beta[0], Beta[1], Beta[2]);
{'fraction_non_alphanumeric': 0.2636928289102202, 'fraction_numerical': 0.10926030491247883, 'mean_word_length': 2.7812166488794023, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '240302', 'n_tokens_mistral': 1976, 'n_tokens_neox': 1827, 'n_words': 441}