powered by
These functions check whether the input is a one-hot matrix, i.e., a numeric matrix where each row contains exactly one entry equal to 1 and all other entries equal to 0.
numeric
1
0
check_one_hot_matrix( x, nrows = NULL, ncols = NULL, tolerance = sqrt(.Machine$double.eps) )assert_one_hot_matrix( x, nrows = NULL, ncols = NULL, tolerance = sqrt(.Machine$double.eps), .var.name = checkmate::vname(x), add = NULL )test_one_hot_matrix( x, nrows = NULL, ncols = NULL, tolerance = sqrt(.Machine$double.eps) )
assert_one_hot_matrix( x, nrows = NULL, ncols = NULL, tolerance = sqrt(.Machine$double.eps), .var.name = checkmate::vname(x), add = NULL )
test_one_hot_matrix( x, nrows = NULL, ncols = NULL, tolerance = sqrt(.Machine$double.eps) )
Same as documented in check_matrix.
check_matrix
[any] Object to check.
any
[integer(1)] Exact number of rows.
integer(1)
[integer(1)] Exact number of columns.
[numeric(1)] A non-negative tolerance value.
numeric(1)
[character(1)] Name of the checked object to print in assertions. Defaults to the heuristic implemented in vname.
character(1)
vname
[AssertCollection] Collection to store assertion messages. See AssertCollection.
AssertCollection
Other matrix helpers: check_correlation_matrix(), check_covariance_matrix(), check_transition_probability_matrix(), cov_to_chol(), diff_cov(), insert_matrix_column(), matrix_diagonal_indices(), matrix_indices(), sample_correlation_matrix(), sample_covariance_matrix(), sample_transition_probability_matrix(), stationary_distribution()
check_correlation_matrix()
check_covariance_matrix()
check_transition_probability_matrix()
cov_to_chol()
diff_cov()
insert_matrix_column()
matrix_diagonal_indices()
matrix_indices()
sample_correlation_matrix()
sample_covariance_matrix()
sample_transition_probability_matrix()
stationary_distribution()
x <- matrix(c( 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 ), nrow = 3, byrow = TRUE) check_one_hot_matrix(x) test_one_hot_matrix(x) if (FALSE) { assert_one_hot_matrix(x) }
Run the code above in your browser using DataLab