De Casteljau's algorithm is used to interpolate a Bézier curve and consists a recursive (or iterative) procedure to reduce the number of linear segments until only one is left and the interpolation gives a single point. Here in the iterative form: import numpy as np import matplotlib.pyplot as plt def de_casteljau(cp, t): interpolated = cp.copy() for i in range(len(cp)-1): p_from = interpolated[:-1] p_to = interpolated[1:] interpolated = t * p_from + (1-t) * p_to return interpolated[0,:] cp = np.array([[268, 113], [293, 226], [284, 277], [206, 146]]) t = np.linspace(0, 1, num=50, endpoint=True
public class Test{ static int add (int m, int n){ return m+n; } public static void main (String[] args){ int a=1; int b=2; int c= add(a,b); } } Assume the above simple code. When I run the line int c = add(a,b); 32 bits of memory are allocated in the call stack for the integer variable c, then the method add is called with parameters 1 and 2. This will create two new areas in memory (in the call stack) for the parameters m and n and assign them the values 1 and 2, respectively. Now the return closes the method add and the memory allocated for m and n is set free again. Then afterwards the valu
On Windows 10 22H2, when I search "vsc" in the start menu, it finds Visual Studio Code. How can I do the same for my own app when it's installed, for example so that a search for "fb" will find my app named "FooBar"? I noticed that it doesn't automatically work for all app names: searching for "ame" can't find "Adobe Media Encoder". I don't see vsc.exe defined in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths, so how is it possible to set up this sort of search alias?
I have a column (of known length) of duration text strings that may contain strings that are not durations. I want to convert just the duration text strings to numbers in minutes: A 14h 58m 30s 22h 28m 1d 7h 27m — Header 1d 20h 2m I extract day, hour, minute, and second numbers to an array, check if any contains a match and if so, sum the minutes: =let(ind_last_row,60 ,time,offset(A1,0,0,ind_last_row,1) ,time_2_arr,lambda(time,REGEXEXTRACT(time,"(\d*d)?\s*(\d*h)?\s*(\d*m)?\s*(\d*s)?")) ,time_arr_2_min,lambda(arr,sumproduct(arrayformula(regexreplace(arr,"[dhms]","")),{1440,60,1,1/60})) ,nomatch
I have a column (of known length) of duration text strings that contains potentially strings that are not duration. And I want to convert just the duration text strings to numbers in minutes. For example, A 14h 58m 30s 22h 28m 1d 7h 27m — Header 1d 20h 2m My plan so far is to extract the day, hour, minute, second numbers into an array for each row and check if any of them contains a real match, and if so, sum up the correct minutes. And thus, my formula is =let(ind_last_row,60 ,time,offset(A1,0,0,ind_last_row,1) ,time_2_arr,lambda(time,REGEXEXTRACT(time,"(\d*d)?\s*(\d*h)?\s*(\d*m)?\s*(\d*s)?")
My logging creates a StreamWriter and FileStream: //Activate Logging try { streamer = new FileStream("filepath and name", FileMode.OpenOrCreate, FileAccess.Write); writer = new StreamWriter(streamer); } I use parameters to create the file name. If an error occurs before this file is created I create another file called "crashlog", which logs the error itself. However, this file is sometimes empty. If an unhandled error occurs, even if the original logfile is created, that file is empty. I believe the log gets dumped in it's entirety once the program exits and the stream/writer are closed. Is t
Given: all numbers are valid BigInts for expanding to 128 bits and beyond buttonArray holds 64 button objects a button is initalized through a .forEach loop and pushed onto buttonArray this makes each button accessible via buttonArray[buttonIndex] it also makes scanning the array quick and easy buttonData holds a 64 x 15 array of each command attribute (button text, command, handler, status word, color, etc.) For this example buttonData[0] is: ["Deploy Landing Gear","Retract Landing Gear*","deploy landing gear","retract landing gear","toggle1","EliteAPI.Gear",0x8000000000000000n,_c._black,_c._
I am trying to replace Joda datetime and interval methods with Java.time and also trying to specify explicitly timezone as Duser.timezone=America/Chicago. This my code fragment public void createMessage(userinfo,long start,long end){ Long startDateInMilliSec = start; Long endDateInMilliSec = end; DateTime startDateTime = new DateTime(start); DateTime endTimeForThisDay = startDateTime.plusDays(1).withMillisOfDay(0); Interval i = new Interval(startDateTime, endTimeForThisDay); ... } I replaced this way ZonedDateTime startDateTime = startInstant.atZone(ZoneId.of("America/Chicago")); Instant endIn
About C23's implementation for #embed, can I use that with extern in a C++ 23 program to have all 3d models and assets in the exe but not in memory all the time, so I can load on demand parts of the binary data to upload to the GPU, then discard them? I can read binary data from files to put in CPU memory, then upload that to the GPU and discard the data afterwards to free CPU memory. Can I do that without needing extra files next to the compiled binary (i.e. all data is in 1 executable, preferably without consuming extra RAM).
I have implemented an authentication workflow using Activities which works fine: a proxy activity launches an Intent to open a web, and during the authentication the web redirects to a separate activity which upon creation signals the first to close itself, all using intents. But after the web intents are closed I need to do extra login postprocessing and it looks a bit ugly to return the user to the first screen, wait a few seconds, then launch them forward into the app. To avoid this I would like to use Multi-tasking with Partial Custom Tabs. And generally it works and looks very well! The u
Is it possible to map the enum values to underlaying data types to use them with std::variant? I want to do something like the example below, but want the std::variant to understand it is an int or double. enum myValues { Int, Double }; std::variant<Int, Double> myVariant;
I want to plot all the diagonals of a matrix. In the matrix, row 1 contains information for time 1, row 2 for time 2, etc. Each diagonal represents the evolution of the number of fish in a cohort that appeared at a given point in time. Is there a built-in function in MATLAB for this problem? This is the smartest code I could think of, but I am missing some lines: close clear clc %A=[10 20 30 45 55;11 22 30 44 51; 10 20 30 40 50; 10 20 35 40 48]; A=[1 2 3 4 5; 1 2 3 4 5; 1 2 3 4 5; 1 2 3 4 5] r=size(A,1); c=size(A,2); p=c-r+1;%number of diagonals T=size(diag(A),1);%T=min(S,N) x=linspace(1,T,T);
Is the minimum range that remquo(x, y, quo) assigns *quo [-7 ... +7]? Is not, what is the minimum compliant range? double remquo(double x, double y, int *quo); has the following description: The remquo functions compute the same remainder as the remainder functions. In the object pointed to by quo they store a value whose magnitude is congruent modulo 2<sup>n</sup> to the magnitude of the integral quotient of x/y, where n is an implementation-defined integer greater than or equal to 3. If the value stored is not zero, its sign is the sign of x/y. C23dr § 7.12.10.3 2 When x and y are finite, y
I have an experimental design with 4 treatments: ambient (control), drought, warmed, and warmed & drought. I sampled these treatments 4 times: pre-drought, peak drought, post drought, and recovery. I want to calculate resistance and resilience of the soil microbial communities in these treatments. I want to use the ambient treatment as the control. In other words, I want to compare the other treatments to ambient at peak and recovery time points. Alternatively, I could also use the pre-drought as the control. In other words, I could compare each treatment at peak and recovery to what that trea
In python 3.12 I have a dictionary of which the keys are 2-tuples of integers and of which the values are integers (as in the function f:N × N → N for which f(n, m) = n + m). What I need is those keys of the dictionary where the first element has a specific value. It's simple enough to write a function like def matching_keys(d: dict[tuple[int, int], int], n: int) -> list[tuple[int, int]]: """ find all the keys in a dictionary *d* whose first element is the integer *n* :param d: the dictionary in question :type d: dict[tuple[int, int], int] :param n: the first-element value *n* in question :typ
When having two selects with one option each like this <select multiple="multiple" size="1"> <option value="0">AAA</option> </select> <select multiple="multiple" size="2"> <option value="0">AAA</option> </select> Firefox renders it like this: and Edge like this: Which is the correct way according to the spec? Is that configurable somehow?
This is the program I am using: fig, ax = plt.subplots(figsize=(4, 4)) t, dt = np.linspace(-4, 4, 10, retstep=True) x = t y = t**3 - 9*t xy = np.stack((x, y), axis=1) n = len(xy) d1ydx1 = np.apply_along_axis(np.gradient, axis=0, arr=xy) ######################## # Normalize all tangents ######################## f = lambda m : m / np.linalg.norm(m) T = np.apply_along_axis(f, axis=1, arr=d1ydx1) for idx in range(n): ax.quiver(xy[idx][0],xy[idx][1],T[idx][0],T[idx][1], color="green") plt.show() The image plotted is: I would like to modify the length of the vectors shown, because I find them too sm
After updating Primefaces version 13 to 14, the rowsPerPageLabel attribute on <p:dataTable> no longer displays the text for dropdown label after setting the attribute "rowsPerPageLabel". Tried setting rowsPerPageLabel directly via paginatorTemplate paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} Rows per page: {RowsPerPageDropdown}" , but it doesn't look good. setting rowsPerPageLabel directly via paginatorTemplate Actual appearance of label if set from attribute in and upto v13 Has the rowsPerPageLabel attribute been deprecat
Circular shifting cshift in fortran as an equivalent in Julia : circshift. But I'am seeking an equivalent of eoshift (https://fortranwiki.org/fortran/show/eoshift) which is a acyclic shifting that pads the new slots with zeros or some another boundary value. For 1D arrays, I can emulate it using diagonal matrices like in eoshift(x, k) = diagm(k=> ones(length(x)-abs(k)))*x but I prefer to find a more built-in way to compute it in Julia Bests, For instance eoshit([1:9;], 2) => 3 4 5 6 7 8 9 0 0 eoshift([1:9;] -2) => 0 0 1 2 3 4 5 6 7
How do I represent a partially loaded tree of objects using C# generics? public class Address { public string Line1 { get; set; } public string City { get; set; } } public class Customer { public string Name { get; set; } public Address Address { get; set; } public ICollection<Order> Orders { get; set; } } public class Order { public int OrderNumber { get; set; } public ICollection<Line> Lines { get; set; } } public class Line { public int Qty { get; set; } public string Product { get; set; } } The classes reference each other but sometimes these references will not be loaded and the fields wi
I have some C# code (in a .NET Standard 2.0 library) that looks like the following: private object MySynchronousOp(object param, object cmnParam) { //Do stuff... return theObject; } private ResponseT Do<ResponseT, RequestT>(Func<RequestT, object, ResponseT> op, RequestT request) { //Do some checks, get/setup cmnParam. return op.Invoke(request, cmnPatam); } public object RunMySynchronousOp(object param) { return Do(MySynchronousOp, param); } This pattern is repeated for many MySynchronousOp and RunMySynchronousOp pairs, using Do to do a common set of checks and provide a valid common parameter.
tl;dr Given a docker image that was saved to a local file, e.g. /tmp/my-image.tar, how do I determine the image digest (SHA256 checksum) that will match what docker expects? Given that I save a docker image to a local file, docker image save my-image --output /tmp/my-image.tar I can ask docker to tell me the image digest (SHA256 checksum) for the image in the registry $ docker images --digests REPOSITORY TAG DIGEST ... my-image tag1 sha256:019cf20c5b98efcd548952d31df1768377916bf8d57d70d979c6c92bfd5e7446 ... But I want to figure out that digest value by reading the file /tmp/my-image.tar. How d
Any C++ class can be first forward declared, and defined only later in the program. Are function-local classes an exception from this rule? Please consider a simplified program: auto f() { struct A { struct B; }; return A{}; } using A = decltype( f() ); struct A::B {}; where struct A::B is only declared inside f(), but defined at the end of the program in the global scope. EDG says that this is not permitted: error: class "A::B" cannot be defined in the current scope GCC crashes with Internal Compiler Error, but both Clang and MSVC accept the program just fine. Online demo Which implementation
I have a class in VB.NET. The definition of this class is re-defined according to need. For example: TR as char(2), F1 as Char(10) then later TS as Char(2) F1 as float. I want to define one class and be able to define 2 derived classes C1 and C2 respectively with the field definitions I mentioned above. Is it possible in VB.NET?
I designed Turing machine that accepts the input over the language: {a^i b^j | j is divisible by i, i ≥ 2, j ≥ 2} This Turing machine should accept and reject the stings as following: aabbbb | Accept bab | Reject aabbbb | Accept aabbbbbbbb | Accept aaaabbbbbbbbb | Reject aaabbbbb | Reject Here is the transition diagram that I draw in JFLAP. After trying so many times, I am still unable to get the desired output:
I am using stripe for payment purposes. Here the thing is that I am passing my stripe key and oauth token to the view in following way: The controller part return view($filepath, [ 'stripe_key' => $this->getApiKey($project), 'oauth_token' => $project->stripe_oauth_token, ]); and inside my view i am using it as @if( !empty($oauth_token) ) const stripe = Stripe("{{ $stripe_key }}", { stripeAccount: "{{ $oauth_token }}" }); @else const stripe = Stripe("{{ $stripe_key }}") @endif How can I secure it in terms that they can be use as well as not shown in the client side. Currently i did was to encod
I'm using Visual Studio Code for website development, HTML, CSS, Javascript and PHP. I'm trying to find a way to start the PHP Server automatically when I load Visual Studio Code. It is just cumbersome to click PHP Server: Server project the first time then click PHP Server: Open file in browser every other time.
I'd like to know what would be the permission of a mutable parameter of a function which holds a mutable reference, and how would the permissions change if the parameter is holding a non-mutable reference? fn mod_string(mut name: &mut String) { *name = "B".to_string(); } For this piece of code, what would be the permissions for name variable in terms of R, O, W, F, as mentioned in the Rust Book? I'm just playing around to get a better understanding of ownership, references and permissions. I'm learning Rust from the experimental Rust Book.
My job runs daily and I want to start a task on the second working day of the month. I can set up another job and use cron pattern 0 0 0 2W ? MON-FRI but I want to keep everything in the same job. A combination of {{job.start_time.day}} and {{job.trigger.time.is_weekday}} in if/else conditions still runs if the first day of the month is a Sunday. How do I check if the current day is the second day, a weekday, and if the previous day is also a weekday? On a month where the second working day is between Tuesday and Friday it works. On a month where the second working day is between Saturday and