MCPcopy Index your code
hub / github.com/CadQuery/cadquery / penaltyMatrix2D

Function penaltyMatrix2D

cadquery/occ_impl/nurbs.py:1335–1419  ·  view source on GitHub ↗

Create sparse tensor product 2D derivative matrices.

(
    u: Array,
    v: Array,
    uorder: int,
    vorder: int,
    dorder: int,
    uknots: Array,
    vknots: Array,
    uperiodic: bool = False,
    vperiodic: bool = False,
)

Source from the content-addressed store, hash-verified

1333
1334@njit
1335def penaltyMatrix2D(
1336 u: Array,
1337 v: Array,
1338 uorder: int,
1339 vorder: int,
1340 dorder: int,
1341 uknots: Array,
1342 vknots: Array,
1343 uperiodic: bool = False,
1344 vperiodic: bool = False,
1345) -> list[COO]:
1346 """
1347 Create sparse tensor product 2D derivative matrices.
1348 """
1349
1350 # extend the knots and pre-process
1351 u_, uknots_ext, minspanu, maxspanu, deltaspanu = _preprocess(
1352 u, uorder, uknots, uperiodic
1353 )
1354 v_, vknots_ext, minspanv, maxspanv, deltaspanv = _preprocess(
1355 v, vorder, vknots, vperiodic
1356 )
1357
1358 # number of parameter values
1359 ni = len(u)
1360
1361 # chunk size
1362 nu = uorder + 1
1363 nv = vorder + 1
1364 nj = nu * nv
1365
1366 # number of basis
1367 nu_total = maxspanu
1368 nv_total = maxspanv
1369
1370 # temp chunk storage
1371 utemp = np.zeros((dorder + 1, nu))
1372 vtemp = np.zeros((dorder + 1, nv))
1373
1374 # initialize the empty matrices
1375 rv = []
1376 for i in range(dorder + 1):
1377 rv.append(
1378 COO(
1379 i=np.empty(ni * nj, dtype=np.int64),
1380 j=np.empty(ni * nj, dtype=np.int64),
1381 v=np.empty(ni * nj),
1382 shape=(
1383 ni,
1384 (len(uknots) - 1 - (not uperiodic) * uorder)
1385 * (len(vknots) - 1 - (not vperiodic) * vorder),
1386 ),
1387 )
1388 )
1389
1390 # loop over parameter values
1391 for i in range(ni):
1392 ui, vi = u_[i], v_[i]

Callers 2

approximate2DFunction · 0.85
constrainedApproximate2DFunction · 0.85

Calls 5

_preprocessFunction · 0.85
COOClass · 0.85
nbFindSpanFunction · 0.85
nbBasisDerFunction · 0.85
appendMethod · 0.80

Tested by

no test coverage detected