<jupyter_start><jupyter_text>Create some matrices<jupyter_code>// Create two matrices of the same size, a and b.
a := mat.NewDense(3, 3, []float64{1, 2, 3, 0, 4, 5, 0, 0, 6})
b := mat.NewDense(3, 3, []float64{8, 9, 10, 1, 4, 2, 9, 0, 2})
c := mat.NewDense(3, 2, []float64{3, 2, 1, 4, 0, 8})
fa := mat.Formatted(a, mat.Prefix("    "))
fb := mat.Formatted(b, mat.Prefix("    "))
fmt.Printf("\na = %0.4v\n\n", fa)
fmt.Printf("b = %0.4v\n\n", fb)<jupyter_output><empty_output><jupyter_text>Matrix addition, multiplication, powers, and apply<jupyter_code>// Add a and b.
d := mat.NewDense(0, 0, nil)
d.Add(a, b)
fd := mat.Formatted(d, mat.Prefix("            "))
fmt.Printf("d = a + b = %0.4v\n\n", fd)

// Multiply a and c.
f := mat.NewDense(0, 0, nil)
f.Mul(a, c)
ff := mat.Formatted(f, mat.Prefix("          "))
fmt.Printf("f = a c = %0.4v\n\n", ff)

// Raising a matrix to a power.
g := mat.NewDense(0, 0, nil)
g.Pow(a, 5)
fg := mat.Formatted(g, mat.Prefix("          "))
fmt.Printf("g = a^5 = %0.4v\n\n", fg)

// Apply a function to each of the elements of a.
h := mat.NewDense(0, 0, nil)
sqrt := func(_, _ int, v float64) float64 { return math.Sqrt(v) }
h.Apply(sqrt, a)
fh := mat.Formatted(h, mat.Prefix("              "))
fmt.Printf("h = sqrt(a) = %0.4v\n\n", fh)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.22145061728395063, 'fraction_numerical': 0.04861111111111111, 'mean_word_length': 3.308970099667774, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '32263', 'license': 'MIT', 'n_tokens_mistral': 627, 'n_tokens_neox': 580, 'n_words': 149, 'path': 'examples/Matrix_Operations.ipynb', 'repo_name': 'cluzeauf/gokernel', 'size': '1296'}