quadratic

Efficient way of calculating quadratic forms: avoid for loops?

喜欢而已 提交于 2019-12-11 07:14:55
问题 I want to calculate N (N is big) quadratic forms. I am using the command 'quad.form' from the R package 'emulator'. How can I implement this without using a for loop? So far, I am using library(emulator) A = matrix(1,ncol=5,nrow=5) # A matrix x = matrix(1:25,ncol=5,nrow=5) # The vectors of interest in the QF # for loop QF = vector() for(i in 1:5){ QF[i] = quad.form(A,x[,i]) } Is there a more direct and efficient way to calculate these quadratic forms? Something intriguing is that quad.form(A

Quadratic Read Method

给你一囗甜甜゛ 提交于 2019-12-08 16:43:50
问题 I have to write a read method for a quadratic class where a quadratic is entered in the form ax^2 + bx + c. The description for the class is this: Add a read method that asks the user for an equation in standard format and set the three instance variables correctly. (So if the user types 3x^2 - x, you set the instance variables to 3, -1, and 0). This will require string processing you have done before. Display the actual equation entered as is and properly labeled as expected output. I was

Quadratic equation solver not working

落花浮王杯 提交于 2019-12-08 12:26:44
问题 I'm trying to create a quadratic equation solver but it doesn't seem to be working when I put in a coefficient greater than 1? The code and error message is below. Any help is greatly appreciated. print "Welcome to the quadratic equation solver." print "The general quadratic equation = ax^2 + bx + c.\n" def POS(a,b): #This function gives the point at which the quadratic turns tp = float((-b)/(a*2)) return (tp) #This allows for the user to input the values of the variables while True: s = raw

R Error : some group is too small for 'qda'

孤街醉人 提交于 2019-12-06 12:32:13
I used the qda{MASS} to find the classfier for my data and it always reported " some group is too small for 'qda' ". Is it due to the size of test data I used for model ? I increased the test sample size from 30 to 100, it reported the same error. Helpppppppp..... set.seed(1345) AllMono <- AllData[AllData$type == "monocot",] MonoSample <- sample (1:nrow(AllMono), size = 100, replace = F) set.seed(1355) AllEudi <- AllData[AllData$type == "eudicot",] EudiSample <- sample (1:nrow(AllEudi), size = 100, replace = F) testData <- rbind (AllMono[MonoSample,],AllEudi[EudiSample,]) plot (testData$mono

Get quadratic equation term of a graph in R

给你一囗甜甜゛ 提交于 2019-12-06 10:31:13
问题 I need to find the quadratic equation term of a graph I have plotted in R. When I do this in excel, the term appears in a text box on the chart but I'm unsure how to move this to a cell for subsequent use (to apply to values requiring calibrating) or indeed how to ask for it in R. If it is summonable in R, is it saveable as an object to do future calculations with? This seems like it should be a straightforward request in R, but I can't find any similar questions. Many thanks in advance for

Can I use '<' and '>' in match?

泪湿孤枕 提交于 2019-12-05 17:29:47
问题 I am trying to do a simple quadratic function that would return number of roots and their values via an enum: enum QuadraticResult { None, OneRoot(f32), TwoRoots(f32, f32), } fn solveQuadratic(a: f32, b: f32, c: f32) -> QuadraticResult { let delta = b * b - 4.0 * a * c; match delta { < 0 => return QuadraticResult::None, > 0 => return QuadraticResult::TwoRoots(0.0, 1.0), _ => return QuadraticResult::OneRoot(0.0), } } This doesn't compile as it complains about '<' and '>'. Is there a way to

C# - Finding Peaks within a Given Width via Quadratic Fit

核能气质少年 提交于 2019-12-04 20:16:40
I'm working on an algorithm to find peaks in a List object. I'd thought up what I thought was a good (or good enough) algorithm for doing this by looking at a point and it's neighbors and, if it was a peak, adding it to the results list. However, given some recent results, I don't think this method works as well as I'd initially hoped. (I've included the code I'm currently using, and hope to replace, below). I've done a little work with LabView before and I know that the way their module finds peaks/valleys works for what I need to do. I did some research into how LabView does this and found

Get quadratic equation term of a graph in R

荒凉一梦 提交于 2019-12-04 15:41:08
I need to find the quadratic equation term of a graph I have plotted in R. When I do this in excel, the term appears in a text box on the chart but I'm unsure how to move this to a cell for subsequent use (to apply to values requiring calibrating) or indeed how to ask for it in R. If it is summonable in R, is it saveable as an object to do future calculations with? This seems like it should be a straightforward request in R, but I can't find any similar questions. Many thanks in advance for any help anyone can provide on this. All the answers provide aspects of what you appear at want to do,

Using points to generate quadratic equation to interpolate data

喜你入骨 提交于 2019-12-04 09:38:08
I'm trying to come up with a flexible decaying score system for a game using quadratic curves. I could probably brute force my way through it but was wondering if anyone can help me come up with something flexible or maybe there are some ready made solutions out there already! But basically I need the ability to generate the values of a,b & c in: y = ax^2 + bx + c from 3 points (which i know fall on a valid quadratic curve, but are dynamic based on configurable settings and maximum times to react to an event) for example: (-1100, 0), (200, 1), (1500, 0). So I can then plugin in values for x to

Solve Quadratic Equation in C++

陌路散爱 提交于 2019-12-04 05:17:34
I am trying to write a function in C++ that solves for X using the quadratic equation. This is what I have written initially, which seems to work as long as there are no complex numbers for an answer: float solution1 = (float)(-1.0 * b) + (sqrt((b * b) - (4 * a * c))); solution1 = solution1 / (2*a); cout << "Solution 1: " << solution1 << endl; float solution2 = (float)(-b) - (sqrt((b*b) - (4 * a * c))); solution2 = solution2 / (2*a); cout << "Solution 2: " << solution2; If, for example, I use the equation: x^2 - x - 6, I get the solution 3, -2 correctly. My question is how would I account for