Matrix multiplication

Share:

Description

Matrix multiplication methods, including diffnet objects. This function creates a generic method for %*% allowing for multiplying diffnet objects.

Usage

1
2
3
4
5
6
7
x %*% y

## Default S3 method:
x %*% y

## S3 method for class 'diffnet'
x %*% y

Arguments

x

Numeric or complex matrices or vectors, or diffnet objects.

y

Numeric or complex matrices or vectors, or diffnet objects.

Details

This function can be usefult to generate alternative graphs, for example, users could compute the n-steps graph by doing net %*% net (see examples).

Value

In the case of diffnet objects performs matrix multiplication via mapply using x$graph and y$graph as arguments, returnling a diffnet. Otherwise returns the default according to %*%.

See Also

Other diffnet methods: as.array.diffnet, as_diffnet, c.diffnet, diffnet-arithmetic, diffnet_index

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# Finding the Simmelian Ties network ----------------------------------------

# Random diffnet graph
set.seed(773)
net <- rdiffnet(100, 4, seed.graph='small-world', rgraph.args=list(k=8))
netsim <- net

# According to Dekker (2006), Simmelian ties can be computed as follows
netsim <- net * t(net) # Keeping mutal
netsim <- netsim * (netsim %*% netsim)

# Checking out differences (netsim should have less)
nlinks(net)
nlinks(netsim)

mapply(`-`, nlinks(net), nlinks(netsim))

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.