Search results for

column

2,047 results found

Post

Replies

Boosts

Views

Activity

Reply to Peculiar EXC_BAD_ACCESS, involving sparse matrices
the sparseMatrix function with comments: extension Array where Element == [Double] { // A sparse matrix is a mattrix where all zero's are ommitted. // Normal matrix: Sparse matrix: // 0 1 0 1 // 1 3 0 1 3 // 4 0 2 4 2 // Find the sparse matrix of this matrix. Returns an array of doubles containing the values of the sparse matrix (omitting all zero's) and a SparseMatrixStructure containing information about where the columns start and where the rows start. The values array of the sparse matrix above would be [1, 4, 1, 3, 2]. func sparseMatrix() -> (structure: SparseMatrixStructure, values: [Double]) { let columns = self.transpose() // Get the row indices of the matrix. The row indices of the sparse matrix above would be // [1, 2 column 0 // 0, 1, column 1 // 2] column 2 var rowIndices: [Int32] = columns.map { column in column.indices.compactMap { indexInColumn in if column[indexInColumn] != 0 { return Int32(indexInColumn) } return nil } }.reduce
Topic: Programming Languages SubTopic: Swift Tags:
Jun ’24
Reply to Peculiar EXC_BAD_ACCESS, involving sparse matrices
The SavitzkyGolay class with comments: class SavitzkyGolay { static func coefficients(windowLength: Int, polynomialOrder: Int, derivativeOrder: Int = 0, delta: Int = 1) -> [Double] { // windowLength is the number of coefficients returned by this function. guard windowLength > 0 else { fatalError(windowLength must be positive) } // polynomialOrder is the order of the polynomial used to smooth the noisy data (the coefficients are calculated independently from the noisy data) guard polynomialOrder < windowLength else { fatalError(polynomialOrder must be less than windowLength) } // The derivativeOrder is the order of the derivative to compute. If it is set to zero, the noisy data is smoothed without differentiating. guard derivativeOrder <= polynomialOrder else { return [Double](repeating: 0, count: windowLength) } let (halfWindow, remainder) = windowLength.quotientAndRemainder(dividingBy: 2) var pos = Double(halfWindow) // pos should not be a round number (because otherwise this function won't work
Topic: Programming Languages SubTopic: Swift Tags:
Jun ’24
WeatherKit REST API new columns for CurrentWeather
My pipeline broke today as new fields were added for the current weather dataset: cloudCoverLowAltPct cloudCoverMidAltPct cloudCoverHighAltPct I presumed new fields would only be released in a new version of the API? Is there any way to use a specific version of the API that will not be subject to change? The current weather REST API docs are here, which don't include these fields: https://developer.apple.com/documentation/weatherkitrestapi/currentweather/currentweatherdata
6
0
1.4k
Jun ’24
Data storage for a Matrix struct when working with Accelerate
I have a Matrix structure as defined below for working with 2D numerical data in Accelerate. The underlying numerical data in this Matrix struct is stored as an Array. struct Matrix { let rows: Int let columns: Int var data: [T] init(rows: Int, columns: Int, fill: T) { self.rows = rows self.columns = columns self.data = Array(repeating: fill, count: rows * columns) } init(rows: Int, columns: Int, source: (inout UnsafeMutableBufferPointer) -> Void) { self.rows = rows self.columns = columns self.data = Array(unsafeUninitializedCapacity: rows * columns) { buffer, initializedCount in source(&buffer) initializedCount = rows * columns } } subscript(row: Int, column: Int) -> T { get { return self.data[(row * self.columns) + column] } set { self.data[(row * self.columns) + column] = newValue } } } Multiplication is implemented by the functions shown below. import Accelerate infix operator .* func .* (lhs: Matr
3
0
923
Jun ’24
Reply to Data storage for a Matrix struct when working with Accelerate
I would also like to mention that running the code below gives me almost identical elapsed times for the matrix array and matrix buffer solutions. So, at least for this case, I'm not seeing any performance differences between the two approaches. func runBenchmark1() { print(Benchmark matrix multiplication) for _ in 1...3 { let tic = Date.now let n = 8_000 let a = Matrix(rows: n, columns: n, fill: 1.5) let b = Matrix(rows: n, columns: n, fill: 2.8) let c = a * b let toc = tic.timeIntervalSinceNow.magnitude let elapsed = String(format: %.4f, toc) print(Elapsed time is (elapsed) sec, first element is (c[0, 0])) } }
Topic: Programming Languages SubTopic: Swift Tags:
Jun ’24
Apple Pay Registration Error
We are getting this error when processing our registration. Payment Services Exception Domain check failed with the following errors. No domains were registered.nDomain verification failed for pspId=1A014B2EC09DB380EE1D51FE4D116C801F62F29D74F2D93269FE554CA2E34656 domain=patient.moolah.cc url=/.well-known/apple-developer-merchantid-domain-association errorMessage=com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 4559 path $, statusCode: 400}
1
0
985
Jun ’24
Reply to About NavigationLink Inside NavigationSplitView's Sidebar
Hi @kittens , You're seeing this behavior because the NavigationSplitView is collapsing down to a stack and showing content based on the content of the split view's columns. Here, it's showing the sidebar, and then navigating to the detail view, so the back button is taking you back to the sidebar no matter what. To change this to the behavior you are looking for, you can put a NavigationStack in the detail view. For example: NavigationSplitView { Text(Here is the FirstView) NavigationLink(Go to SecondView) { SecondView() } } detail: { NavigationStack { Text(nothing selected yet) } } Hope this helps, Sydney
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’24
Xcode 13: Active breakpoint turns to an outline when app is run.
I'm working on several apps that were developed on Xcode 12.5. Using Xcode 13.1, I set a breakpoint, which correctly appears as the blue marker in the left-hand column of the editor. When I run the apps (in a simulator), the breakpoint turns to an outline of a breakpoint marker, with a dotted blue outline and a white interior. The apps do not stop at the breakpoint. Breakpoints work as expected on an app started in Xcode 13.1. I've dug through the docs but find nothing that describes what the outline breakpoint means or how to make it work. I've done all the standard stuff: cleaned the build folder, deleted derived data. What does the outline breakpoint marker mean, and how do I get breakpoints working in Xcode 13.1 when debugging code developed originally on Xcode 12.5? Thanks in advance for any help. John
19
0
19k
Jun ’24
UICollectionView minimumLineSpacing bug
I'm creating a horizontal scroll view through the collection view. I used flowlayout for layout, and I set the scroll direction to horizontal. I found a bug in this situation. If the width of the item is different, line spacing is not applied, but item spacing is applied. Since it is a horizontal scroll, line spacing should be applied in the direction of the column, but item spacing is applied. Does anyone know anything about this? // // ViewController.swift // minimumLineSpacingTest // // Created by Hoonki chae on 2023/07/12. // import UIKit class TestCell: UICollectionViewCell { } class ViewController: UIViewController { let collectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()) override func viewDidLoad() { super.viewDidLoad() self.view.backgroundColor = .white self.collectionView.frame = .init(origin: .init(x: 0, y: 100), size: .init(width: self.view.frame.width, height: 50)) self.view.addSubview(self.collectionView) self.collectionView.backgroundColor
Topic: UI Frameworks SubTopic: UIKit Tags:
1
0
578
Jul ’23
tvOS Context Menu on LazyVGrid is selecting item below.
Context menu on tvOS LazyVGrid selecting wrong item. It works fine if selecting items on last row. Testing on code from https://developer.apple.com/videos/play/wwdc2024/10207/ I just added contextMenu LazyVGrid(columns: columns, spacing: 40) { ForEach(sortedMatchingAssets) { asset in Button {} label: { asset.landscapeImage .resizable() .aspectRatio(16 / 9, contentMode: .fit) .contextMenu { Button(Test) {} } Text(asset.title) } .buttonStyle(.borderless) } } Attached video with the bug - https://www.icloud.com/iclouddrive/020zq2PxZ_E_1Pr0vE86-8aww#Screen_Recording_2024-06-13_at_9.26.15%E2%80%AFPM
2
0
585
Jun ’24
How to implement multiple selection types in NavigationSplitView?
In the sidebar column of the NavigationSplitView I'd like to have several sections. All the items are fetched with Core Data. View all photos (Photos entity in Core Data) Folder (Folder entity in Core Data) Folder A Folder B Folder C Tags (Tag entity in Core Data) Cat Dog In the content view, I'd like show the items based on the selection in the sidebar. I tried the following with some success but I think there should be another way of doing this. NavigationSplitView() { List(selection: $navigationModel.selectedCategory, content: { NavigationLink(value: Category(type: .all, predicate: NSPredicate(value: true), title: View all items) ) { Text(View all items) } Section { ForEach(folders){ folder in NavigationLink(value: Category(type: .folder, predicate: NSPredicate(format: folder == %@, folder), title: folder.name) ) { FolderRow(folder: folder) // ... and so on. Another section for tags And in the content: ZStack{ List(selection: $navigationModel.selectedPhoto) { ContentView(photos: FetchRequest( sort
2
0
1k
Jun ’24
How to: Compositional layout with self-sizing rows of N columns where the height of each item is set to the tallest item in its row
Paging Steve Breen! 😄 I've seen this question asked a zillion times but I've never seen an answer. Is it possible to configure compositional layout to give you a grid of N columns (say 2 or 3) where each item in each row/group self-size their height, but the heights of those items are then set to be the height of the tallest item in their row. This is easy to do if you ignore the self-sizing requirement (just use a fixed or absolute item height), but on the surface this doesn't even appear to be possible if you require self-sizing. What I've Tried Configuring a layout where the items are set to a fractional height of 1.0 and their group is set to an estimated height (ex: 100). I was hoping compositional layout would interpret this as, Please self-size the height of the group and make each item 100% of that height. Unfortunately, compositional layout just uses the estimate you provide for the height as the actual height and no self-sizing occurs at all. Sad panda. 🐼 Use visibleItemsInvalidationHandl
Topic: UI Frameworks SubTopic: UIKit Tags:
4
0
5.4k
Jun ’24
Xcode - Sqlite versions
In Xcode (Mac OS Catalina), when trying to create an application to access a database, I receive syntax errors, resulting from the installed version of SQlite (below 3.30) does not allowing generation of virtual columns. After updating to 3.46 the version installed on system, this does not occur if I execute such queries directly in SQlite, via Terminal. How do I get Xcode to access and use the system updated version ? Thanks in advance
2
0
711
May ’24
Reply to App primary language doesn't appears in Appstore
Xcode creates one .lproj folder for each localization when compiling your String Catalog, so you can still check the existence of en.lproj by looking into your app bundle. Note that Xcode creates the .lproj folder only when the localization contains at least one localized string. As an example, if you select your String Catalog in Xcode, and see that the strings under the Enlgish (en) column are all gray, Xcode won't create en.lproj for you. So be sure that you add at least one localized string (which will then be shown in black) for your English localization. Best, —— Ziqiao Chen  Worldwide Developer Relation.
May ’24
Magnification gesture to scale ScrollView's content.
Hello! I am trying out new SwiftUI and I have to say that I love it, but I've got some problems implementing few features. First issue is that I am not sure how can I scale content of ScrollView, to make content of that View smaller, but there would be more subviews visible. Here's my code: @State private var scale: CGFloat = 1.0 var body: some View { ScrollView([.horizontal]) { HStack(alignment: .top) { ForEach(0..<5, id: .self) { _ in ScrollView(.vertical) { LazyVGrid(columns: [GridItem(.fixed(300), spacing: 10)], spacing: 10) { ForEach(0..<5, id: .self) { _ in Rectangle() .frame(width: 300, height: 300, alignment: .center) } } } .padding(.leading, 10) } } .scaleEffect(scale) } .gesture( MagnificationGesture() .onChanged { value in scale = value.magnitude }) } } If You paste that code to a project, You will see that app scales whole ScrollView, not its content. And when we're talking about gestures, I would really appreciate if someone would share here how can I prioritize the gestures. Thank
2
0
2.6k
Nov ’21