From 8e2d0c383e50760c0562855da3e09047b9c79d46 Mon Sep 17 00:00:00 2001
From: Michiel Cottaar <michiel.cottaar@ndcn.ox.ac.uk>
Date: Wed, 6 Mar 2024 14:11:56 +0000
Subject: [PATCH] Remove dependency on linA

---
 Project.toml                         |  1 -
 src/components/abstract_types.jl     |  2 --
 src/components/pulses/sinc_pulses.jl | 10 ++++------
 src/containers/linearise.jl          |  1 -
 4 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/Project.toml b/Project.toml
index e5be776..83c65d6 100644
--- a/Project.toml
+++ b/Project.toml
@@ -7,7 +7,6 @@ version = "0.0.0"
 Ipopt = "b6b21f68-93f8-5de0-b562-5493be1d77c9"
 JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
 Juniper = "2ddba703-00a4-53a7-87a5-e8b9971dde84"
-LinA = "f599c993-2677-4f60-8998-71feb0f665db"
 LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
 MakieCore = "20f20a25-4f0e-4fdf-b5d1-57303727442b"
 Polynomials = "f27b6e38-b328-58d1-80ce-0feddd5e7a45"
diff --git a/src/components/abstract_types.jl b/src/components/abstract_types.jl
index 7695919..6ef5cb2 100644
--- a/src/components/abstract_types.jl
+++ b/src/components/abstract_types.jl
@@ -40,8 +40,6 @@ abstract type ReadoutComponent <: EventComponent end
     split_times(component, t1, t2, precision)
 
 Indicates at what timepoints a given [`BaseComponent`](@ref) should be split during linearisation to achieve the given precision.
-
-For non-linear components this will use [`LinA.jl`](https://github.com/LICO-labs/LinA.jl) under the hood.
 """
 function split_times end
 
diff --git a/src/components/pulses/sinc_pulses.jl b/src/components/pulses/sinc_pulses.jl
index ec343f0..fa562c9 100644
--- a/src/components/pulses/sinc_pulses.jl
+++ b/src/components/pulses/sinc_pulses.jl
@@ -1,7 +1,6 @@
 module SincPulses
 import JuMP: @constraint
 import QuadGK: quadgk
-import LinA
 import ....BuildSequences: global_model
 import ....Variables: duration, amplitude, effective_time, flip_angle, phase, inverse_bandwidth, VariableType, set_simple_constraints!, frequency, make_generic, get_free_variable
 import ...AbstractTypes: RFPulseComponent, split_times
@@ -103,11 +102,10 @@ function make_generic(block::SincPulse)
 end
 
 function split_times(block::SincPulse, t1, t2, precision)
-    real_amplitude_precision = precision * amplitude(block)
-    pwl = LinA.Linearize(t -> amplitude(block, t), t1, t2, LinA.Absolute(real_amplitude_precision))
-    times = [part.xMin for part in pwl]
-    push!(times, t2)
-    return times
+    max_second_derivative = π^2/3 * (amplitude(block) / lobe_duration(block))^2
+    step_size = sqrt(2 * precision / max_second_derivative)
+    npoints = Int(div(t2 - t1, step_size, RoundUp))
+    return range(t1, t2, length=npoints)
 end
 
 end
\ No newline at end of file
diff --git a/src/containers/linearise.jl b/src/containers/linearise.jl
index 6b170d6..5ca43bd 100644
--- a/src/containers/linearise.jl
+++ b/src/containers/linearise.jl
@@ -1,5 +1,4 @@
 module Linearise
-import LinA
 import StaticArrays: SVector
 import ...Components: GradientWaveform, split_times
 import ...Variables: amplitude, phase, gradient_strength3, duration
-- 
GitLab