Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-36313

VEC_DISTANCE_COSINE return error value

Details

    Description

      sql: SELECT VEC_DISTANCE_COSINE(VEC_FROMTEXT('[1,2,3]'), VEC_FROMTEXT('[0,0,0]'));
      return value is 0.

      static double calc_distance_cosine(float *v1, float *v2, size_t v_len)
      {
        double dotp=0, abs1=0, abs2=0;
        for (size_t i= 0; i < v_len; i++, v1++, v2++)
        {
          float f1= get_float(v1), f2= get_float(v2);
          abs1+= f1 * f1;
          abs2+= f2 * f2;
          dotp+= f1 * f2;
        }
        return 1 - dotp/sqrt(abs1*abs2);
      }
      

      abs1 or abs2 maybe zero, so in this caseļ¼Œ1 should be returned

      Attachments

        Issue Links

          Activity

            Transition Time In Source Status Execution Times
            Sergei Golubchik made transition -
            Open Closed
            6h 56m 1

            People

              serg Sergei Golubchik
              myx myx
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.