@@ -40,16 +40,6 @@ parent_type(::Type{T}) where {T} = T
40
40
parent_type (:: Type{R} ) where {S,T,A,N,R<: Base.ReinterpretArray{T,N,S,A} } = A
41
41
parent_type (:: Type{Diagonal{T,V}} ) where {T,V} = V
42
42
43
- """
44
- has_parent(::Type{T}) -> StaticBool
45
-
46
- Returns `static(true)` if `parent_type(T)` a type unique to `T`.
47
- """
48
- has_parent (x) = has_parent (typeof (x))
49
- has_parent (:: Type{T} ) where {T} = _has_parent (parent_type (T), T)
50
- _has_parent (:: Type{T} , :: Type{T} ) where {T} = False ()
51
- _has_parent (:: Type{T1} , :: Type{T2} ) where {T1,T2} = True ()
52
-
53
43
"""
54
44
buffer(x)
55
45
@@ -370,151 +360,6 @@ end
370
360
"""
371
361
can_avx (:: Any ) = false
372
362
373
- """
374
- insert(collection, index, item)
375
-
376
- Returns a new instance of `collection` with `item` inserted into at the given `index`.
377
- """
378
- Base. @propagate_inbounds function insert (collection, index, item)
379
- @boundscheck checkbounds (collection, index)
380
- ret = similar (collection, length (collection) + 1 )
381
- @inbounds for i = firstindex (ret): (index- 1 )
382
- ret[i] = collection[i]
383
- end
384
- @inbounds ret[index] = item
385
- @inbounds for i = (index+ 1 ): lastindex (ret)
386
- ret[i] = collection[i- 1 ]
387
- end
388
- return ret
389
- end
390
-
391
- function insert (x:: Tuple{Vararg{Any,N}} , index:: Integer , item) where {N}
392
- @boundscheck if ! checkindex (Bool, StaticInt {1} (): StaticInt {N} (), index)
393
- throw (BoundsError (x, index))
394
- end
395
- return unsafe_insert (x, Int (index), item)
396
- end
397
-
398
- @inline function unsafe_insert (x:: Tuple , i:: Int , item)
399
- if i === 1
400
- return (item, x... )
401
- else
402
- return (first (x), unsafe_insert (tail (x), i - 1 , item)... )
403
- end
404
- end
405
-
406
- """
407
- deleteat(collection, index)
408
-
409
- Returns a new instance of `collection` with the item at the given `index` removed.
410
- """
411
- Base. @propagate_inbounds function deleteat (collection:: AbstractVector , index)
412
- @boundscheck if ! checkindex (Bool, eachindex (collection), index)
413
- throw (BoundsError (collection, index))
414
- end
415
- return unsafe_deleteat (collection, index)
416
- end
417
- Base. @propagate_inbounds function deleteat (collection:: Tuple{Vararg{Any,N}} , index) where {N}
418
- @boundscheck if ! checkindex (Bool, StaticInt {1} (): StaticInt {N} (), index)
419
- throw (BoundsError (collection, index))
420
- end
421
- return unsafe_deleteat (collection, index)
422
- end
423
-
424
- function unsafe_deleteat (src:: AbstractVector , index:: Integer )
425
- dst = similar (src, length (src) - 1 )
426
- @inbounds for i in indices (dst)
427
- if i < index
428
- dst[i] = src[i]
429
- else
430
- dst[i] = src[i+ 1 ]
431
- end
432
- end
433
- return dst
434
- end
435
-
436
- @inline function unsafe_deleteat (src:: AbstractVector , inds:: AbstractVector )
437
- dst = similar (src, length (src) - length (inds))
438
- dst_index = firstindex (dst)
439
- @inbounds for src_index in indices (src)
440
- if ! in (src_index, inds)
441
- dst[dst_index] = src[src_index]
442
- dst_index += one (dst_index)
443
- end
444
- end
445
- return dst
446
- end
447
-
448
- @inline function unsafe_deleteat (src:: Tuple , inds:: AbstractVector )
449
- dst = Vector {eltype(src)} (undef, length (src) - length (inds))
450
- dst_index = firstindex (dst)
451
- @inbounds for src_index in OneTo (length (src))
452
- if ! in (src_index, inds)
453
- dst[dst_index] = src[src_index]
454
- dst_index += one (dst_index)
455
- end
456
- end
457
- return Tuple (dst)
458
- end
459
-
460
- @inline unsafe_deleteat (x:: Tuple{T} , i:: Integer ) where {T} = ()
461
- @inline unsafe_deleteat (x:: Tuple{T1,T2} , i:: Integer ) where {T1,T2} =
462
- isone (i) ? (x[2 ],) : (x[1 ],)
463
- @inline function unsafe_deleteat (x:: Tuple , i:: Integer )
464
- if i === one (i)
465
- return tail (x)
466
- elseif i == length (x)
467
- return Base. front (x)
468
- else
469
- return (first (x), unsafe_deleteat (tail (x), i - one (i))... )
470
- end
471
- end
472
-
473
- """
474
- is_lazy_conjugate(::AbstractArray) -> Bool
475
-
476
- Determine if a given array will lazyily take complex conjugates, such as with `Adjoint`. This will work with
477
- nested wrappers, so long as there is no type in the chain of wrappers such that `parent_type(T) == T`
478
-
479
- Examples
480
-
481
- julia> a = transpose([1 + im, 1-im]')
482
- 2×1 transpose(adjoint(::Vector{Complex{Int64}})) with eltype Complex{Int64}:
483
- 1 - 1im
484
- 1 + 1im
485
-
486
- julia> ArrayInterfaceCore.is_lazy_conjugate(a)
487
- True()
488
-
489
- julia> b = a'
490
- 1×2 adjoint(transpose(adjoint(::Vector{Complex{Int64}}))) with eltype Complex{Int64}:
491
- 1+1im 1-1im
492
-
493
- julia> ArrayInterfaceCore.is_lazy_conjugate(b)
494
- False()
495
-
496
- """
497
- is_lazy_conjugate (:: T ) where {T<: AbstractArray } = _is_lazy_conjugate (T, False ())
498
- is_lazy_conjugate (:: AbstractArray{<:Real} ) = False ()
499
-
500
- function _is_lazy_conjugate (:: Type{T} , isconj) where {T<: AbstractArray }
501
- Tp = parent_type (T)
502
- if T != = Tp
503
- _is_lazy_conjugate (Tp, isconj)
504
- else
505
- isconj
506
- end
507
- end
508
-
509
- function _is_lazy_conjugate (:: Type{T} , isconj) where {T<: Adjoint }
510
- Tp = parent_type (T)
511
- if T != = Tp
512
- _is_lazy_conjugate (Tp, ! isconj)
513
- else
514
- ! isconj
515
- end
516
- end
517
-
518
363
"""
519
364
fast_scalar_indexing(::Type{T}) -> Bool
520
365
0 commit comments