% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/weighted_jaccard.R
\name{c_weighted_jaccard_sparse}
\alias{c_weighted_jaccard_sparse}
\title{Sparse weighted Jaccard similarity via C++}
\usage{
c_weighted_jaccard_sparse(
  x,
  transpose = FALSE,
  display_progress = TRUE,
  threads = 4L,
  triangle = FALSE,
  distance = FALSE
)
}
\arguments{
\item{x}{A \link[Matrix:dgCMatrix-class]{dgCMatrix} (sparse column-compressed matrix)}

\item{transpose}{If \code{FALSE} (default), compare columns; if
\code{TRUE}, compare rows.}

\item{display_progress}{Whether to show a text progress bar (default
\code{TRUE}).}

\item{threads}{Number of threads for parallel computation (default 4).
Set to 0 to use all available cores.}

\item{triangle}{If \code{TRUE}, return a symmetric \code{dsCMatrix}
(upper triangle only). If \code{FALSE} (default), return a general
\link[Matrix:dgCMatrix-class]{dgCMatrix}.}

\item{distance}{If \code{TRUE}, return distance (\code{1 - similarity})
instead of similarity. Default \code{FALSE}. A warning is issued since
sparse distance matrices are typically dense.}
}
\value{
A sparse similarity (or distance) matrix: \code{dsCMatrix} when
  \code{triangle = TRUE}, \link[Matrix:dgCMatrix-class]{dgCMatrix} otherwise.
}
\description{
Compute the weighted Jaccard similarity matrix for a
\link[Matrix:dgCMatrix-class]{dgCMatrix}, returning a
sparse result. Uses \code{weighted_jaccard_sparse_fill} to compute min-sums
only for column (or row) pairs that share at least one non-zero feature, then
normalises to similarity. Only the upper triangle is computed, taking
advantage of the symmetry of the Jaccard index.
}
\examples{
\dontrun{
library(Matrix)
m <- sparseMatrix(i = c(1,2,1,2,3,3), j = c(1,1,2,2,2,3),
                  x = c(4,2,1,3,3,1), dims = c(3,3))
c_weighted_jaccard_sparse(m)
}
}
\seealso{
\code{\link{c_weighted_jaccard_dense}} for the dense equivalent
}
