SparseSet: R6 class for a fuzzy set with sparse internal representation

Description Methods Examples

Description

This class implements the data structure and methods for fuzzy sets.

Methods

Public methods


Method new()

Creator for objects of class SparseSet

Usage
SparseSet$new(attributes, M = NULL)
Arguments
attributes

(character vector) Names of the attributes that will be available in the fuzzy set.

M

(numeric vector or column Matrix) Values (grades) to be assigned to the attributes.

Details

If M is omitted, the fuzzy set is the empty set. Later, one can use the assign method to assign grades to any of its attributes.

Returns

An object of class SparseSet.


Method assign()

Assign grades to attributes in the set

Usage
SparseSet$assign(attributes = c(), values = c(), ...)
Arguments
attributes

(character vector) Names of the attributes to assign a grade to.

values

(numeric vector) Grades to be assigned to the previous attributes.

...

key = value pairs, where the value value is assigned to the key attribute name.

Details

One can use both of: S$assign(A = 1, B = 0.3) S$assign(attributes = c(A, B), values = c(1, 0.3)).


Method [()

Get elements by index

Usage
SparseSet$[(indices)
Arguments
indices

(numeric, logical or character vector) The indices of the elements to return. It can be a vector of logicals where TRUE elements are to be retained.

Returns

A SparseSet but with only the required elements.


Method cardinal()

Cardinal of the SparseSet

Usage
SparseSet$cardinal()
Returns

the cardinal of the SparseSet, counted as the sum of the degrees of each element.


Method get_vector()

Internal Matrix

Usage
SparseSet$get_vector()
Returns

The internal sparse Matrix representation of the set.


Method get_attributes()

Attributes defined for the set

Usage
SparseSet$get_attributes()
Returns

A character vector with the names of the attributes.


Method length()

Number of attributes

Usage
SparseSet$length()
Returns

The number of attributes that are defined for this fuzzy set.


Method print()

Prints the set to console

Usage
SparseSet$print()
Returns

A string with the elements of the set and their grades between brackets .


Method to_latex()

Write the set in LaTeX format

Usage
SparseSet$to_latex(print = TRUE)
Arguments
print

(logical) Print to output?

Returns

The fuzzy set in LaTeX.


Method clone()

The objects of this class are cloneable with this method.

Usage
SparseSet$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples

1
2
3
4
S <- SparseSet$new(attributes = c("A", "B", "C"))
S$assign(A = 1)
print(S)
S$to_latex()

neuroimaginador/fcaR documentation built on Dec. 9, 2020, 5:42 a.m.