code: public static double dot(SparseArray x, SparseArray y) {
          Iterator<SparseArray.Entry> it1 = x.iterator();
          Iterator<SparseArray.Entry> it2 = y.iterator();
          SparseArray.Entry e1 = it1.hasNext() ? it1.next() : null;
          SparseArray.Entry e2 = it2.hasNext() ? it2.next() : null;
  
          double s = 0.0;
          while (e1 != null && e2 != null) {
              if (e1.i == e2.i) {
                  s += e1.x * e2.x;
                  e1 = it1.hasNext() ? it1.next() : null;
                  e2 = it2.hasNext() ? it2.next() : null;
              } else if (e1.i > e2.i) {
                  e2 = it2.hasNext() ? it2.next() : null;
              } else {
                  e1 = it1.hasNext() ? it1.next() : null;
              }
          }
          
          return s;
      }
docs: Returns the dot product between two sparse arrays.