Skip to content

Commit

Permalink
#21
Browse files Browse the repository at this point in the history
# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date:      Mon Aug 9 22:15:57 2021 +0900
#
# interactive rebase in progress; onto 67aa73a
# Last command done (1 command done):
#    edit 01c8fb1 fixed #21
# No commands remaining.
# You are currently editing a commit while rebasing branch 'master' on '67aa73a'.
#
# Changes to be committed:
#	new file:   Matft.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
#	modified:   Sources/Matft/util/common/order.swift
#	modified:   Sources/Matft/util/library/vDSP.swift
#	modified:   Tests/MatftTests/ConversionTest.swift
#
  • Loading branch information
jjjkkkjjj committed Aug 9, 2021
1 parent 67aa73a commit e0ee43b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
8 changes: 8 additions & 0 deletions Matft.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
14 changes: 7 additions & 7 deletions Sources/Matft/util/common/order.swift
Original file line number Diff line number Diff line change
Expand Up @@ -204,35 +204,35 @@ internal func check_contiguous(_ mfarray: MfArray, _ mforder: MfOrder? = nil) ->
}
}
}
internal func check_biop_contiguous(_ l_mfarray: MfArray, _ r_mfarray: MfArray, _ mforder: MfOrder = .Row, convertL: Bool = true) -> (l: MfArray, r: MfArray, biggerL: Bool, retstoredSize: Int){
internal func check_biop_contiguous(_ l_mfarray: MfArray, _ r_mfarray: MfArray, _ mforder: MfOrder = .Row, convertL: Bool = true) -> (l: MfArray, r: MfArray, biggerL: Bool, retsize: Int){
let l: MfArray, r: MfArray
let biggerL: Bool
let retstoredSize: Int
let retsize: Int
if r_mfarray.mfflags.column_contiguous || r_mfarray.mfflags.row_contiguous{
l = l_mfarray
r = r_mfarray
biggerL = false
retstoredSize = r_mfarray.storedSize
retsize = r_mfarray.size
}
else if l_mfarray.mfflags.column_contiguous || l_mfarray.mfflags.row_contiguous{
l = l_mfarray
r = r_mfarray
biggerL = true
retstoredSize = l_mfarray.storedSize
retsize = l_mfarray.size
}
else{
if convertL{
l = Matft.conv_order(l_mfarray, mforder: mforder)
r = r_mfarray
biggerL = true
retstoredSize = l.storedSize
retsize = l.size
}
else{
l = l_mfarray
r = Matft.conv_order(r_mfarray, mforder: mforder)
biggerL = false
retstoredSize = r.storedSize
retsize = r.size
}
}
return (l, r, biggerL, retstoredSize)
return (l, r, biggerL, retsize)
}
6 changes: 3 additions & 3 deletions Sources/Matft/util/library/vDSP.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ fileprivate func _run_biop_vv<T: MfStorable>(lptr: UnsafePointer<T>, _ lstride:
internal func biop_vv_by_vDSP<T: MfStorable>(_ l_mfarray: MfArray, _ r_mfarray: MfArray, vDSP_func: vDSP_biop_vv_func<T>) -> MfArray{
// biggerL: flag whether l is bigger than r
//return mfarray must be either row or column major
let (l_mfarray, r_mfarray, biggerL, retstoredSize) = check_biop_contiguous(l_mfarray, r_mfarray, .Row, convertL: true)
let (l_mfarray, r_mfarray, biggerL, retsize) = check_biop_contiguous(l_mfarray, r_mfarray, .Row, convertL: true)


let newdata = withDummyDataMRPtr(l_mfarray.mftype, storedSize: retstoredSize){
let newdata = withDummyDataMRPtr(l_mfarray.mftype, storedSize: retsize){
dstptr in
let dstptrT = dstptr.bindMemory(to: T.self, capacity: retstoredSize)
let dstptrT = dstptr.bindMemory(to: T.self, capacity: retsize)

l_mfarray.withDataUnsafeMBPtrT(datatype: T.self){
[unowned l_mfarray] (lptr) in
Expand Down
5 changes: 5 additions & 0 deletions Tests/MatftTests/ConversionTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,11 @@ final class ConversionTests: XCTestCase {
[ 5, -1]])
}

do {
let a = Matft.arange(start: 0, to: 11, by: 1)
XCTAssertEqual(a.ufuncReduce(Matft.add).toArray() as! [Int], [55])
}

do{
let a = MfArray([[1, 3, 5],
[2, -4, -1]])
Expand Down

0 comments on commit e0ee43b

Please sign in to comment.