w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Combining solve and dsolve to solve equation systems with differential and algebraic equations
Now I assumed that you wanted the code to be rather general, so I made it to be able to work with any given number of equations and any given number of variables, and I did no calculation by hand. Note that the way that the symbolic Toolbox works changes drastically from year to year, but hopefully this will work for you. Now one can add the equation Eq1 to the list of inputs of dSolve but there are two problems with that: One is that dSolve seems to prefer character inputs and the second is that dSolve doesn't seem to realize that there are 3 independent variables a, b, and c (it only sees 2 variables, b and c). To solve the second problem, I differentiated the original equation to get a new differential equation, there were three problems with that: the first is Matlab evaluated the d

Categories : Matlab

How to solve _.some using _.every?
Pass _every a function that returns an inversion of the result from truthStatementFunction: _.some = function(collection, truthStatementFunction) { return !(_every(collection, function(v) { return !truthStatementFunction(v); })); } To answer the second part of your question: and is there a better way to solve this using _.every? There is definitely a better way to solve this than using _.every. Just iterate over the collection, and return true as soon as you find any element that matches. Much more efficient in cases where _.some is going to return true, since you don't really care how many elements in the collection satisfy the predicate, as long as there is at least one. _.some = function(c, pred) { for(var i = 0; i < c.length; i++) { if (pred(c

Categories : Javascript

SQL to solve this
I suggest select * from tableA a1 where a1.status = 1 and not exists (select 1 from tableA a2 where a2.status = 0 and a2.date > a1.date and a2.date < (select max(date) from tableA a3 where a3.status = 1 ) ) Doubly nested subquery. Select rows where the status is 1 that have no rows before them with (status is 0 and that are after the earliest row where status is 1). No idea how efficient this is.

Categories : SQL

How can I solve this using BIT?
Are you determined to use BITs? I would have thought ordinary arrays would do. I would start by creating three arrays of size k, where arrayA[i] = the number of values of a in range equal to i mod k, arrayB[i] = the number of values of b in range where b^2 = i mod k, and arrayC[i] = the number of values of c in range where c^3 = i mod k. N and k are both <= 10^5 so you could just consider each value of a in turn, b in turn, and c in turn, though you can be cleverer if k is much smaller than n, because will be some sort of fiddly fence-post counting expression that allows you to work out how many numbers in the range 0..n are equal to i mod k for each i. Given those three arrays then consider each possible pair of numbers i, j where 0<=i,j < k and work out that there are arrayA[i]

Categories : C++

How to solve the javascript get value in URl
You can do some stuf like making some operations on the id before sendin it, but these operations should be reversable (multiply, devide ...) to do the same thing on the server side to know what's the real number wich is sent by the View. Hope it Helps

Categories : Javascript

Efficient way to solve (A & N) + (B & N) + (C & N)
If you are combining bit masks then you may get what you need with: (A & N) | (B & N) |... in that case you will do better with (A|B|C|...) & N. N.B. if N = 0x0020 and A = 0x003f, B=0x0a25 then: (A & N) + (B & N) = 0x0040 but (A|B)&N = 0x0020 which is more often what is needed when combining bit fields.

Categories : C

How to solve this error XML?
You are trying to do xml parsing in UIThread (Main Thread) which is possibly causing the crash. Any task which needs little longer time or network activity should be done in other thread. In case you block UI thread for longer time, app crashes. Thy doing that work in AsyncTask.

Categories : Android

How to solve this recurrence?
BACKGROUND The original question is about how to tile a 2*n rectangle with 4 types of tiles. What is unusual is that the tiling must divide into two pieces. HINT 1 However, you can also consider this as a way of tiling this with the original 4 tiles coloured red, and another set of 4 tiles coloured blue such that the final board has a red side and a blue side. HINT 2 Let f(n) be the number of ways of tiling a 2*n rectangle with just red tiles, and h(n) be the number of ways of tiling a 2*n rectangle with 0 or more columns of red tiles followed by 1 or more columns of blue tiles. HINT 3 You can now find a simple matrix multiplication that gives the next values of h and f in terms of their two previous values and use the standard matrix power exponentiation to find the final values.

Categories : Algorithm

getting error and help me to solve this c
void print(int j,book[j]) should be void print(int j , struct books *books) and this printf("The name of book %d is %s",j,book.book_name); printf(" The author of book %d is %s",j,book.book_author); printf(" The id of book %d is %d",j,book.book_id); should be printf("The name of book %d is %s",j,books-<book_name); printf(" The author of book %d is %s",j,books->book_author); printf(" The id of book %d is %d",j,books->book_id); and here you need to change: print(int j,book[j]); to print(int j, &book[j]); When you declare a function like here void print(int j,book[j]) You also have to specify the type, which is missing. If you intended to use the array directly, without passing it to print, then you would have to make it global

Categories : C

How to solve ArrayIndexOutofBoundsException
split does remove empty elements. You need to use the two parameter version: str.split(",",-1); See here: Java String split removed empty values

Categories : Java

How to solve this issue with CTE?
You use the term "leaves", which means jobs that have no destinations (as opposed to intermediate nodes in the tree). Here is one approach. Start with all the leaves, then climb up the tree attaching all the nodes they are under. Then select the ones that belong to the job you are interested in: with cte as ( select DestinationJobId as JobId, DestinationJobId as parent, 1 as level from jobs2jobs jj where DestinationJobId not in (select SourceJobId from jobs2jobs) union all select cte.JobId, jj.SourceJobId, level + 1 from cte jobs2jobs jj on cte.Parent = jj.DestinationJobId ) select * from cte where parent = @YourJobId;

Categories : SQL

I need to solve .net OOM issue
How did you conclude you had an OOM issue? An exception? What exception? Debugger output ? What debugger output? A memory dump of 1.9 GB is very large. This makes it likely that your OOM is caused by being out of memory..... before you shout there are other things which throw an OutOfMemory exception. If there are no managed objects over 85k, then it is either unmanaged memory or a very large number of objects less than 85k. This could for example be a map, linked-list or tree or similar, or your own hierarchy of objects. If it's Unmanaged memory the top candidate would definitely be the bitmaps. Loading 11000 bitmaps doesn't seem like a terribly good idea. I suggest you not do that - why not use something like an "x" or similar? Also, what does Resources.Resources.delete do? It look

Categories : Dotnet

C++ inheritance, how solve this?
A couple of things. One, you don't need to cast stuff to (Base*). Implicit conversions will do that for you already. Second, if you define your functions as virtual it will call the proper function for you.

Categories : C++

How to solve the recurrence T(n)=T(n-1) + ... T(1) +1?
Since T(n-1) = T(n-2) + ... + T(1) + 1 T(n) = T(n-1) + T(n-2) + ... + T(1) + 1 = T(n-1) + T(n-1) = 2*T(n-1) and T(1) = 1 => T(n) = 2^(n-1)

Categories : Algorithm

How to solve these two Queries?
For your first query, if you already have a list of all the departments with the number of projects they control, you have the work done. Add a little extra code to your query to finish the job. If you ORDER BY the number of projects descending, the correct department will be the first in the list. And if you LIMIT 1, you will only SELECT that department. Your second query needs more work, it does not provide the information you are looking for as cleanly as the first one. Do the same trick again, first get the information in order, then look for the top one. Your inner query should probably look something like this: (SELECT Essn, COUNT(Dependent_name) AS Dependents FROM Dependent GROUP BY Essn ORDER BY Dependents DESC);

Categories : Mysql

How to solve this join in EF
Simplest solution will be defining navigation property for modules in your Role entity: public class Role { // ... public virtual ICollection<Module> Modules { get; set; } } Then you will be able to do eager loading of roles with modules: var roles = _context.Role.Include(r => r.Modules).ToList(); If your junction table is complex, then create navigation property of ICollection<RoleModule> type which holds both Role and Module. Query will look like: var query = from r in context.Roles select new { Role = r, Modules = r.RoleModules.Select(rm => rm.Module) };

Categories : C#

C# solve simplest equations
Are you sure NCalc wouldn't do what you need? Take a look at an example from http://ncalc.codeplex.com/. Define parameters, even dynamic or expressions Expression e = new Expression("Round(Pow([Pi], 2) + Pow([Pi2], 2) + [X], 2)"); e.Parameters["Pi2"] = new Expression("Pi * [Pi]"); e.Parameters["X"] = 10; e.EvaluateParameter += delegate(string name, ParameterArgs args) { if (name == "Pi") args.Result = 3.14; }; Debug.Assert(117.07 == e.Evaluate()); Please note this is untested - but it looks like you could do something like this with NCalc: var e = new Expression("[A] + [B]"); e.Parameters = /* your input */ var result = e.Evaluate();

Categories : C#

How to solve these logcat errors?
Errors shown in that view are compilation errors. That's not what he wants. He wants runtime errors. He is doing it correctly, however he doesn't seem to be pasting his entire logcat output, as none of the lines he has posted are error lines. EDIT: Or rather, they are system-level errors that can be ignored by the developer as they are handled by the system automatically. What you need to be watching for are uncaught exceptions, such as NullPointerException, or IllegalStateException, etc... These are application-level errors and ones that you need to fix.

Categories : Java

How can i solve CALayer exception?
A NaN means "Not a Number". You may also sometimes see inf, which stands for "infinity". This happens when floating point calculations result in an infinity or an undefined value. Usually it's the result of either a divide by 0 error or an uninitialized variable. It means that at some point, you're setting your CALayer's position to an invalid floating point value. You can check values for NaNs by calling the standard C macro isnan(), though according to this page, it's not portable. FWIW, I've had good luck using it. (There's also an isinf() macro for checking for infinities.) You might also have luck using the static analyzer to see if you have any uninitialized variables. (Or turn on the compiler warning for uninitialized variables if it's not already on.)

Categories : IOS

Solve equation with a set of points
Since you have more points than unknown coefficients, you'll want to do a least squares fit. This calculation will give you the coefficients that minimize the mean square error between the function and all the points. So substitute your 50 points into the assumed equation and get 50 equations for 3 coefficients. This is easily expressed as a matrix: Ax = b where the unknown vector x are your coefficients. Premultiply both sides by the transpose of A and solve using a matrix solver. Start by plotting the data you have. The choice of equation you start with will make your job easier or harder. Are you certain about that leading term? If that wasn't appropriate, you could take the natural log of both sides and it's a simple linear equation. The leading term makes that harder to te

Categories : Python

How to solve this "error in your SQL syntax"
The query where it fails on is: "select * from apps.drinks where drink_name is ='" + listBox1.Text + "'; " there you have is = which is incorrect, remove is so the query looks like: "select * from apps.drinks where drink_name ='" + listBox1.Text + "'; " Also take the comment of w0lf seriously and use prepared statements to prevent SQL injection.

Categories : C#

How to solve a div positioning issue
I would recommend removing height: 100% from the .project and .project-group classes in your stylesheet. My guess is that setting a 100% height on an element is interacting poorly with the overflow: hidden statement from #home-projects.

Categories : CSS

Cannot solve Classnotfound Exception
NoClassDefFoundError are always because of incorrect or incomplete builds, or errors in class path. I always go through the following checklist when getting this error: Clean project Check files and directories Check build path Try again. Never fails. :)

Categories : Java

How to solve a simple optimization in R
You need to use function solnp in package Rsolnpbecause it allows constraints based on an equality. The idea is to build a function to minimize and your equality function for the constraint. Fun <- function(param){ e <- total_observations/(sum(param[1]*var1)+sum(param[2]*var2)+sum(param[3]*var3)+sum(param[4]*var4)) output <- (param[1]*var1 + param[2]*var2 + param[3]*var3 + param[4]*var4)/e -cor(output, observations) #We want to maximize cor and therefore minimize -cor } eqn <- function(param){sum(param)} With your example data: observations <- c(1000,250,78,0,0,90) total_observations=1418 var1=c(1,0.3,0.5,0.01,0.05,0.6) var2=c(500,40,40,0,0,100) var3=c(1,0.1,0.2,0,0.1,0) var4=c(2,0.04,0.003,0.003,0,0.05) Your optimization: solnp(c(.1,.2,.3,.4),fun=Fu

Categories : R

How to solve misalignment in boxlayout?
Interchange values of jl.setAlignmentX(0) 0 to 1 and 1 to 0 .in msgbox or ChatPaneMsgBox classes which are given here. Like if (ij) { this.setLayout(new FlowLayout(FlowLayout.LEFT)); //rest code jl.setAlignmentX(1); //rest code here } else { this.setLayout(new FlowLayout(FlowLayout.Right)); //rest code jl.setAlignmentX(0); //rest code here } even i think now jl.setAlignmentX(); doesn't matter anymore. Thanks a lot to @mKorbel & @kleopatra for their help & suggestions. :-)

Categories : Java

Can't solve undefined references
undefined reference to `btCapsuleShape::btCapsuleShape(float, float)' This constructor is supposed to be defined in the BulletCollision library. These are the libraries I am using: ... BulletCollision The most likely explanation is that you did something like this: g++ -lBulletCollision ... main.cc Don't do that. The order of source and object files and libraries on command line matters, and your order is likely wrong.

Categories : C++

C++ using lists to solve sudoku
Well you can create an array of sets by doing std::array<std::set<int>,81> possibleValues; for example. You can fill this array with all possibilities by writing const auto allPossible = std::set<int>{ 0, 1, 2, 3, 4, 5, 6, 7, 8 }; std::fill( std::begin(possibleValues), std::end(possibleValues), allPossible ); if you are using a modern C++11 compiler. This is how you can set/clear and test each entry: possibleValues[x+9*y].insert( n ); // sets that n is possible at (x,y). possibleValues[x+9*y].erase( n ); // clears the possibility of having n at (x,y). possibleValues[x+9*y].count( n ) != 0 // tells, if n is possible at (x,y). If performance is an issue, you might want to use bit operations rather than (relatively) heavyweight std::set operations. In this case

Categories : C++

How to solve "words-cut" when there's spaces?
For me it works by adding white-space: nowrap; in [data-msg]::before {} Demo http://jsfiddle.net/QHD3A/

Categories : HTML

How to solve Undefined Index in PHP
A common idiom is to do this $a = isset($_POST['salary']) ? $_POST['salary'] : ''; This will set $a to the posted value if set, and use a default if not.

Categories : PHP

Why doesn't B::f solve the ambiguity but A::f does?
A using-declaration acts as an ordinary declaration: it hides outer scope declarations, but it does not suppress argument-dependent lookup (ADL). When you do using B::f you basically change nothing at all. You simply redeclare B::f in local scope, where it was already visible anyway. That does not prevent ADL from finding A::f as well, which creates ambiguity between A::f and B::f. If you do using A::f, the local declaration of A::f hides the outer declaration of B::f. So B::f is no longer visible and no longer found by unqualified name lookup. Only A::f is found now, meaning that there's no ambiguity anymore. It is not possible to suppress ADL. Since the argument in your case is of A::X type, function A::f will always be found by ADL for unqualified name f. You can't "exclude" it from

Categories : C++

Best way to solve an equation in form f(x)=K*u(x)
Your equations are not yet in standard form, yet are reducible to it. Compute >> syms u1 u2 f3 f4; >> K = magic(4); >> f = [2 3 f3 f4].'; >> u = [u1 u2 9 7].'; >> K*u - f ans = 16*u1 + 2*u2 + 116 5*u1 + 11*u2 + 143 9*u1 + 7*u2 - f3 + 138 4*u1 + 14*u2 - f4 + 142 In which I altered the formatting for clarity. From this we can see that if we define b = [-116 -143 -138 -142].'; A = [16 2 0 0 5 11 0 0 9 7 -1 0 4 14 0 -1]; Then we have an equation in standard form A*X = b where X = [u1 u2 f3 f4].' Then, it is a simple matter of >> X = A ans = -5.963855421686747e+000 % u1 -1.028915662650603e+001 % u2 +1.230120481927711e+00

Categories : Matlab

Solve the datarow code?
There is no column name to sort, you need to pass column name which you need to sort DataRow[] dr = dt.Select("" + ColumnName + "='" + strLetter + "'" + " order by " + ColumnName + " asc");

Categories : C#

How to solve a ResourcesNotFoundException in Android
Change id.setText(obj.getId()); with id.setText(String.valueOf(obj.getId())); if you pass an int as argument for a TextView android will look for a String with id the int you provide. If it does not found throws an exception

Categories : Android

Solve this PHP database error for me
You have built foreign key constraints, but apparently you don't understand their purpose. A foreign key enforces a business rule, which is the relationship between the referencing and referenced table: the parent table must have a row with a key which matches the referencing key in the child table. In your scenario a row in the Product_TB needs a Client_ID which matches a row in the Client_TB table. The error message is telling you that this is not the case. So, before you can insert that Product you must insert a row for the client.

Categories : PHP

How can i solve using Dynamic Programming
Instead of solving the whole problem for you I will try to give you a few tips: Don't write a function that computes the sum in interval [a,b] instead write a function that computes the sum in the interval [0,x] and than you have: SUM([a,b]) = SUM([0, b]) - SUM([0, a-1]) In order to compute the sum of digits up to a given limit L, for each digit d compute how many times it is met as a digit in all the numbers up to L. To do that compute how many times d appears as units digit, how many times it appears as tens digit and so on.

Categories : C++

How to solve this SQL query in a shorter way?
I would suggest using a join statement. It makes your intentions clearer. I'm assuming each customer has one ID, c_id. That means that we can group the transactions by the customer IDs. SELECT c_id, SUM (tSaleAmount - tPaymentAmount) AS totalDebt FROM Trans GROUP BY c_id We now have a table with two columns, the customer ID and the customer's total debt. However, you also want to include the customer information. This information is contained in the Customer table with an associate customer ID. This means we can join these two tables on the ID. SELECT Customer.c_id, cName, cSurname, cPbx, cGsm, cLastVisitDate, totalDebt FROM Customer JOIN (SELECT c_id, SUM (tSaleAmount - tPaymentAmount) AS totalDebt FROM Trans GROUP BY c_id) Trans ON Customer.c_id = Trans.c_id WHERE tot

Categories : SQL

Please help solve these exceptions, android?
By Reducing/Scale size of the Image you can get rid out of the Out of Memory Exception, Try this BitmapFactory.Options options = new BitmapFactory.Options(); options.inSampleSize = 8; Bitmap receipt = BitmapFactory.decodeFile(photo.toString(),options); //From File You can customise on your needs.

Categories : Android

In C#,maybe it's a bug for Image.SaveAdd, who can help me to solve it?
From Microsoft Developer Center: You cannot use SaveAdd to add frames to an animated gif file. In order to construct an animated gif, you will need to step through each frame in the animation. A good example of this is shown on VCSKicks or same code here on Stackoverflow.

Categories : C#

How can I solve my localhost issue on mac?
Here: POST localhost:9000/data/customer.json 404 (Not Found) failed You should know, when using HTTP request, PHP server expects to get existing file and transfer it to client (if this file has .php extension - execute script and send stdout). Also PHP allows you to do internal redirection via .htaccess file configuration. For example: (1)ErrorDocument 404 /path-to-file (if requested file was not found on server) (2)ErrorDocument 403 /path-to-file (if requested file was found on server but it was forbidden for direct access) I suggest you to use the both methods. Create an .htaccess file on /data/ with this content: deny from all ErrorDocument 403 /data-manager.php ErrorDocument 404 /data-manager.php Create 'data-manager.php' right on top directory ('public-html'). And via php scr

Categories : Javascript

How to solve the error: MethodNotAllowedHttpException
It's looks like this one: No route found for "GET /user/register": Method Not Allowed (Allow: POST) You have to define requirements _method for you route, like: routeName: pattern: /yourPattern defaults: { _controller: AcmeBundle:Sth:action } requirements: _method: POST|GET

Categories : PHP



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.