|
108 | 108 | ], |
109 | 109 | "source": [ |
110 | 110 | "// Add a and b.\n", |
111 | | - "d := mat.NewDense(0, 0, nil)\n", |
| 111 | + "d := new(mat.Dense)\n", |
112 | 112 | "d.Add(a, b)\n", |
113 | 113 | "fd := mat.Formatted(d, mat.Prefix(\" \"))\n", |
114 | 114 | "fmt.Printf(\"d = a + b = %0.4v\\n\\n\", fd)\n", |
115 | 115 | "\n", |
116 | 116 | "// Multiply a and c.\n", |
117 | | - "f := mat.NewDense(0, 0, nil)\n", |
| 117 | + "f := new(mat.Dense)\n", |
118 | 118 | "f.Mul(a, c)\n", |
119 | 119 | "ff := mat.Formatted(f, mat.Prefix(\" \"))\n", |
120 | 120 | "fmt.Printf(\"f = a c = %0.4v\\n\\n\", ff)\n", |
121 | 121 | "\n", |
122 | 122 | "// Raising a matrix to a power.\n", |
123 | | - "g := mat.NewDense(0, 0, nil)\n", |
| 123 | + "g := new(mat.Dense)\n", |
124 | 124 | "g.Pow(a, 5)\n", |
125 | 125 | "fg := mat.Formatted(g, mat.Prefix(\" \"))\n", |
126 | 126 | "fmt.Printf(\"g = a^5 = %0.4v\\n\\n\", fg)\n", |
127 | 127 | "\n", |
128 | 128 | "// Apply a function to each of the elements of a.\n", |
129 | | - "h := mat.NewDense(0, 0, nil)\n", |
| 129 | + "h := new(mat.Dense)\n", |
130 | 130 | "sqrt := func(_, _ int, v float64) float64 { return math.Sqrt(v) }\n", |
131 | 131 | "h.Apply(sqrt, a)\n", |
132 | 132 | "fh := mat.Formatted(h, mat.Prefix(\" \"))\n", |
|
0 commit comments