YangConway: Construct singly even order magic square (Yang-Hui Conway...

View source: R/YangConway.R

YangConwayR Documentation

Construct singly even order magic square (Yang-Hui Conway generalization)

Description

Construct singly even order magic square (Yang-Hui Conway generalization)

Usage

YangConway(m, d_type = "square", template_set = 2)

Arguments

m

Positive integer, final order n = 2*(2*m+1)

d_type

Type of common difference: "unit" (d=1) or "square" (d=(2m+1)^2)

template_set

Template series: 1~4 corresponding to matrices 4,7,9,10 in the paper

Value

n x n magic square

Examples

# Example 1: Reproduce Yang-Hui 6th order magic square (Yang diagram),
# m=1, d_type="square", template_set=2
cat("===== Yang-Hui 6th order magic square (Yang diagram) =====\n")
yanghui6 <- YangConway(m = 1, d_type = "square", template_set = 2)
print(yanghui6)
cat("Is it a magic square: ", is_magic_square(yanghui6), "\n\n")
# Example 2: Construct 10th order magic square (matrix 8 in the paper),
# m=2, d_type="square", template_set=2
cat("===== 10th order magic square (Yang-Hui method, template 7) =====\n")
yanghui10 <- YangConway(m = 2, d_type = "square", template_set = 2)
print(yanghui10)
cat("Is it a magic square: ", is_magic_square(yanghui10), "\n\n")
# Example 3: Use common difference 1 (LUX method) to construct 10th order magic square, template 4
cat("===== 10th order magic square (LUX method, template 4) =====\n")
lux10 <- YangConway(m = 2, d_type = "unit", template_set = 1)
print(lux10)
cat("Is it a magic square: ", is_magic_square(lux10), "\n\n")

YangHuiMagic documentation built on March 23, 2026, 5:07 p.m.