Lines Matching refs:n

7     "# libCEED for Python examples\n",
8 "\n",
9 …oject.org/) (CEED) of the [Exascale Computing Project](https://www.exascaleproject.org/) (ECP).\n",
10 "\n",
18 "## Setting up libCEED for Python\n",
19 "\n",
36 "## CeedVector\n",
37 "\n",
38 …edVectors constitute the main data structure and serve as input/output for `libceed.Operator`. \n",
39 "\n",
49 "import libceed\n",
50 "\n",
51 "ceed = libceed.Ceed()\n",
52 "\n",
53 "n = 10\n",
54 "x = ceed.Vector(n)"
86 "import numpy as np\n",
87 "\n",
88 "ceed = libceed.Ceed()\n",
89 "x = ceed.Vector(size=3)\n",
90 "\n",
91 "a = np.arange(1, 4, dtype=\"float64\")\n",
92 "x.set_array(a, cmode=libceed.USE_POINTER)\n",
93 "\n",
94 "with x.array_read() as b:\n",
111 "ceed = libceed.Ceed()\n",
112 "x = ceed.Vector(size=5)\n",
113 "\n",
114 "x.set_value(10)\n",
115 "\n",
132 "ceed = libceed.Ceed()\n",
133 "n = 10\n",
134 "\n",
135 "x = ceed.Vector(n)\n",
136 "y = ceed.Vector(n)\n",
137 "\n",
138 "a = np.arange(1, 1 + n, dtype=\"float64\")\n",
139 "x.set_array(a, cmode=libceed.USE_POINTER)\n",
140 "\n",
141 "with x.array() as x_array:\n",
142 " y.set_array(x_array, cmode=libceed.USE_POINTER)\n",
143 "\n",
144 "with y.array_read() as y_array:\n",
145 " print(y_array)\n"
161 "n = 10\n",
162 "\n",
163 "x = ceed.Vector(n)\n",
164 "a = np.zeros(n, dtype=\"float64\")\n",
165 "x.set_array(a, cmode=libceed.USE_POINTER)\n",
166 "\n",
167 "with x.array() as b:\n",
168 " b[3] = -3.14;\n",
185 "n = 10\n",
186 "x = ceed.Vector(n)\n",
187 "\n",
188 "a = np.arange(0, n, dtype=\"float64\")\n",
189 "for i in range(n):\n",
190 " if (i % 2 == 0):\n",
191 " a[i] *= -1\n",
192 "x.set_array(a, cmode=libceed.USE_POINTER)\n",
193 "\n",
194 "norm_1 = x.norm(normtype=libceed.NORM_1)\n",
195 "print(norm_1)\n",
196 "\n",
197 "norm_2 = x.norm()\n",
198 "print(norm_2)\n",
199 "\n",
200 "norm_max = x.norm(normtype=libceed.NORM_MAX)\n",
217 "ceed_gpu = libceed.Ceed('/gpu/cuda')\n",
218 "\n",
219 "n = 10\n",
220 "x = ceed_gpu.Vector(n)\n",
221 "\n",
222 "a = np.arange(1, 1 + n, dtype=\"float64\")\n",
223 "x.set_array(a, cmode=libceed.USE_POINTER)\n",
224 "\n",
225 "with x.array_read(memtype=libceed.MEM_DEVICE) as device_array:\n",