Solve linear equations - Block tridiagonal matrix

Hello

I developed a vi that can be used to solve tridiagonal systems by block of equations by Thomas algorithm. These systems are usually in the finite differences method used to solve equations in partial derivatives.

For iterations of 1000 times, its time is ~ 500ms. Now, I want to finish the work within 100ms. is possible to improve the performance?

Thanks, Jong Hyun

For details of the Thomas algorithm, please see wikipedia Web page, http://en.wikipedia.org/wiki/Thomas_algorithm. Note that it describes how to solve tridiagonal linear equations, but same logic can be applied to block tridiagonal equations.

* If you use the vi sparse SLE of analysis multi-hearts and Sparse Matrix Toolkit, the elapsed time is 450 ms ~

LabVIEW basic/full/pro all use Intel MKL library for linear algebra on MS Windows and Linux.  Intel MKL designed to be very fast for large matrices and breaking a problem given out to take advantage of the different levels of cache. Linear algebra calls go through several levels of functions, including size controls, if any, and may allocate memory for the workspace each call, before finally calculate the result.  This overload problem is evident when the matrix is so small (3 x 3).

I coded matrix-matrix, versions multiply, matrix-vector multiply, and matrix opposite in the case of 3 x 3 explicitly in soil using the structure in place and full indexation (no loops, all scalar operations).  This eliminates the overhead of controls and allows better and placeness.  This brings your reference point down for ~ 70ms on my machine.  Unfortunately this requires significant code changes if you change the block size, but it provides good performance.

"I think that, if I can save each submatrix conversely in the first round and use several times, then speed will be better."

I agree.  You should be able to calculate the most sweeping toward the front of the algorithm and simply replace the submatrices changed and still solve before.  This may mean re - organize the variables to have the submatrices updated or modified down to the right of the input matrix.

-Jim

Tags: NI Software

Similar Questions

  • FIRST HP: Solving a system of linear equations with a parameter

    Hello

    I know how to solve a system of linear equations by using a setting by hand but I don't know how to set up in the calculator.

    Can someone please help me solve the system of linear equations below with a 'p' on the first HP Calculator next parameter?

    2 x + 8z = 26

    4 x-4y-14z = - 38

    8 x - 4y + 2z = 14

    The answer to the above equations is:

    x = 13 - 4, =(45-15p)/2, z = p y p

    Thank you

    Arthur

    Hello

    What you're trying to solve is not really a system of equation with a parameter, but you try to solve a set of 2 equations with 2 variables (x and y).

    The case solve command can do for you.

    According to the CASE, type:

    Solve ([(2*x+8*z) = 26,(4*x-4*y-14*z) = - 38,(8*x-4*y+2*z) = 14], [x, y])

    Come in

    and the calculator will return

    {[-4 * z + 13, 15/2 * z + 45/2]}

    which is what you want.

    Cyrille

  • Systems of linear equations

    Hello

    Does anyone know if there is such AS classes or functions to solve systems of linear equations? On the form A * x = c. A is a square matrix, x is a vector of unknown, and c are constants.

    In other words, a system of equations with a number of well-known (1-5) and an equal number of equations.

    Here is an implementation of the elimination, Gaussian, that you can use.  There is no error checking included:

    package com.kglad {}

    public class Gaussian_Elimination {}

    public void solveF(a:Array):Array {}

    for (var pivotCol:int = 0; pivotCol<>

    a = pivotF(a,pivotCol);

    var factor: number;

    for (var row: int = pivotCol + 1; row)<>

    factor = a [row] [pivotCol];

    for (var _col:int = pivotCol; _col)<>

    a = [line] [_col] has [pivotCol] [_col] * factor;

    }

    }

    }

    Return echelonF (a);

    }

    private void pivotF(a:Array,pivotCol:int):Array {}

    var maxAbs:Number = 0;

    var maxRow:int;

    for (var row: int = 0; line)<>

    {if (Math.ABS (a [Row] [pivotCol]) > maxAbs)}

    maxRow = row.

    maxAbs = Math.abs (a [row] [pivotCol])

    }

    }

    pivotCol line swap with maxRow

    var tempA:Array = a [pivotCol];

    normalize the maxRow

    var number: max = a [maxRow] [pivotCol];

    for (var i: int = 0; i<>

    a [maxRow] [i] / = max;

    }

    [pivotCol] = a [maxRow];

    a [maxRow] = tempA;

    return a;

    }

    private void echelonF(a:Array):Array {}

    var years: Array = [];

    var last: int = a [0] .length-1;

    for (var row: int = 0; line)<>

    var term: Number = 0;

    for (var num:int = 0; num<>

    duration = [line] [last-num-1] * and [num];

    }

    end += [line] [last];

    ans.push(Term/a[Row][Last-Row-1]);

    }

    Return ans.reverse ();

    }

    }

    }

  • Non-linear equations

    Hello

    Is there a way to solve non-linear equations and find x and y of them using LabVIEW MathScript and MatLAB (do not have those on the PC lab)?

    Maybe someone has an example...

    Thank you.

    When I ran your VI, I got error-23023. When I go explain that error and I get ill start dimension. Error-23001 is a syntax error. In your second equation you sqrt (x ^ 2 - y ^ 2) while the equation in your initial post was a +, not a-.  Gives me a syntax error, but nonetheless find a zero.

    The reason for the error-23023 is that you have specified the start but not end. create a control for end and enter two values immediately find a zero to 1518.178612...

    Here is the VI I've used.  You may need to recreate a link to the reference to the function VI because it will be in a different location.

    Lynn

  • Just me, or is the 50g low in solving differential equations?

    Hi all

    I used Ti-89 s widely in the past, as well as the Ti-NSpire CX CASE and now the 50 g for about 1.5 years. I love some aspects of the 50g (sensation of keys, ease of unit, RPN conversion), but I can't help but notice some areas where it reallllly hangs out of the competition.

    It is an example that I really noticed recently in solving differential equations. So far, several examples I've tried (all immediately resolved by my Ti - 89 and Nspire CX CASE), the 50g smothered on each.

    A very simple example: solve y "= - 9.8, with boundary conditions y (0) = 2.9 and y'(0) = 3.8.  This can be solved by hand in about one minute, but the 50g can't do. If I input ['d1d1Y (X) =-9.8' ' Y (0) = 2.9 ' ' d1Y (0) = 3.8 '] in level 2 on the stack, then 'Y' on a level and then run desolve, it returns "Error: Undefined result.

    I missing something here, or is - this really unable to resolve such a differential equation based? I thought that advanced and 'better' mathematical capacity HP CASE was meant to be one of the reasons why it takes precedence over offers from Ti, but I must say, so far I do not see that.

    Josh

    Hello!

    Try with the exact numbers:

    ["d1d1Y (X) =-49/5 ' ' Y (0) = 29/10 ' ' d1Y (0) = 19/5 '"]

    « Y »

    DESOLVE

    (after SIMPLIFICATION) You'll get years:

    {Y (X) =-(49*X^2-38*X-29)/10}

  • non-linear system Solver more equations than unknowns

    Is it possible to solve a nonlinear system with more equations than unknowns in LabView. I do a triangulation and data from several sensors, so I'm able to write 6 equations in order to get the 3 coordinates (x, y, z) as a solution. In LabView, I was able only to solve a system of 3 equations with this 3 unknowns, but I would use the set of 6 equations in order to obtain a more accurate solution, given that some measures can be noisy.

    Thanks in advance

    You can use the non-linear curve code to solve this problem. Consider the following system:

    3XY + y - z = 12

    yx + x ^ 2 + z = 12

    x - y - z = - 2

    Arrange to get 0 right side. x, y and z are the paramneters to be in shape. The entrance to the curved Fti.vi Y non linear will be an array of three zeros. Initial settings will be an array of three values, for example [1 1 1]. An example is attached.

    -Jim

  • Main calculator HP cannot solve simple equation

    Hello

    I am trying to solve

    solve ((2) ^ (x) = x ^ 2, x)

    But the calculator cannot solve, or I do something wrong?

    I lost my TI Nspire CX and I have HP 1, is from a recent modern version, have been able to resolve something simple that I'm wrong. (TI Nspire resolved).

    How to solve the above equation using the first HP? I seriusly thinking to return it back.

    Thank you

    After that I played with the calculator, I found there in the CASE of the environment so that the Solver to work, if the fsolve is used in the home environment, it won't work:

    fsolve (2 ^ x = x ^ 2, x,-10.. 10)-> [-.76664695962 2 1.8]

    nSolve works too, but it does not have an interval.

    So the solution is that these commands should be used in environmental CASES.

    Thank you

  • Solve complex equations stored on the HP50g

    Hello

    I stored the 2 equations Δ & K, but when I try to solve in the Num. solv. I get the message bad guess (es). I searched on google and it seems that it is because I work with complex numbers and the num solv. can't handle them.  However, I have not found the way to solve them. I use two equations, so it would be great if you could help me find a solution where I can solve them enter the values of the variables, just like with the num solv.

    FYI, make sure you go back and read your old post... the method to enter the equations with existing values using EQW is demonstrated in the last entry and unfortunately was added after you received the answer to your question...

    Here's the simplest method

    all four variables stored... S11, S12, S21, S22,

    Press the following keys...

    EVAL

    selection for DELTA key

    Come in

    EVAL

    selection for K key

    Come in

    There is another method by using the MENU (30)

    However, I have to work on the process I'm not as familiar with the algebraic entry mode...

    unless another Member of the forum knows how to use MENU (30) in algebraic mode and can post the post-processing.

    will try to send the process later tonight...

    MENU 30 is generally described beginning on page 6-26 of the 50G (not the user manual) User Guide

    the section is the title "Submenu SOLVR"

    the manual describes the process as

    MENU (74)

    Come in

    Press F1 (root)

    Press F1 (solvr)

    MENU (30)

    Come in

    is direct access

  • HP 40GS systems of linear equation with parameters

    Hello

    I'm in the learning curve of the HP 40GS - a very interesting tool.

    Is it possible to solve systems of equations with parameters, for example:

    A * X + Y = 2 * 12

    5 * X - 3 * A * Y = 5

    HP 50 g, this isn't a big deal, but with HP 40GS I don't have an idea so far.

    If this is not possible, it will be possible if I have a third equation (so 3 equations in 3 unknowns)?

    Thank you very much in advance,

    Joachim

    P.S.: So far, I feel very comfortable with the HP 40GS and menus!

    ----------------------------------------
    I am not a member of the HP Calculator development team - unfortunately!

    Hello

    now, I found a way to calculate the systems of equations with symbolic coefficients:

    See the document: http://www.hp.com/ctg/Manual/c00829737.pdf to page 346ff

    With the command 'linsolve', it is possible to calculate with more unknown than equations.

    I hope this helps anyone with the same or close problem.

    Have fun with your calculators and do not hesitate to write other ways of calculations.

    Greetings,

    Joachim

  • Solve mathematical equations in Action Script 2.0

    Hello surfers.

    We have a problem in Action Script 2.0 to solve the math equation given below:

    write a code in Action Script 2.0 to solve these two equations.

    Objective: Know the value of 'a' in the two different equations.

    1. 2A + 5 = 3 a + 1

    2. 4A + 3 = 11

    Thanks in advance.

    Thanks to give me as soon as POSSIBLE, I struggle here.

    :

    function solveLinearEquationF (b1:Number, m2:Number, m1:Number, b2:Number) {}

    {if(M1!=M2)}

    return (b2 - b1) /(m1-m2);

    } else {}

    if(B1 == B2) {}

    return "all the number."

    } else {}

    don't return "no number";

    }

    }

    }

  • Solve mixed content blocking

    I clicked on the shield and disabled the blocking of mixed content for a page. How to re - activate the blocking of the page?

    Thank you

    The thermostat should work only in the current tab and it should be sufficient to close the tab and open the same page in a new tab.

  • How to solve an equation that has integration

    Dear Sir.

    I need to implement an equation like below:

    I have checked several VI mathematics and box tools treatment but unable to fulfil my obligation of signals. Kindly help me with suggestions.

    with respect,

    Sri

    This isn't really a question of LabVIEW, but a simple calculation a.

    The integral show you is a definite integral between values: 0 and 'b '. I guess that the 'a' is a constant value, so just integrate it by the variable 'b', simply by using the rule of the definite integral:

    -2 * a * (b - 0) = - 2ab.

    So if you have the value of a and b, you can use just to function multiply in LabVIEW.

  • Solve this linear system HP50g

    Hi guys,.
    I am an engineer in electrical engineering and have to solve systems of linear equations on a regular basis, so that the functionality is very important for me. Everything works very well, 95% of the time but sometimes I meet systems that the HP50g doesn't seem to like. For example one below.

    I want to solve for x, y, z and one in terms of V

    V- 100000 x +is-100000 100000x= 0
    -250000is-V+ 100000x100000z= 0
    -250000z+ 100000one+ 100000y= 0
    a+ 100000-250000z= 0

    After these 4 equations is on the stack, I'm them in a vector by pushing {4} in the stack and then by pressing -> ARRY. Then I push the variables I want to solve for the battery, x, y, z and a and a vector of them. Then, I use LINSOLV to solve the system. However, when I do it this way, the calculator gives me an equation for x, an equation for y and 2 equations for z and no equation for s. I'm not sure what I'm doing wrong. Is there another way to do that would give me 4 equations, one for each variable I want to solve for in terms of V?

    If my method to solve linear equations is somehow confusing, I basically followed this video
    http://www.YouTube.com/watch?v=z802L29JyQE

    Thanks in advance.

    Hello

    Do not know exactly how you typed, so I'm being explicit just for some b:

    Notes:

    (1) as an equation is entered, use ' '

    (2) it is preferable to use a comma to separate the real and imaginary parts

    (3) explicit use multiply

    If the entry will look like this:

    '(4,3*X) = (4.7)'

    For this simple equation and assuming that X is defined as an independent variable (reproduced by 'X' in the top middle of the screen), you can use SOLVEVX for this one: (No. 5 in S.SLV menu or F5 if you use soft-keys)

    with "_Approx" uncontrolled, the answer is:

    X = 7/3

    with "vabout" checked the answer is:

    X = (2.333333333,0) (although X is part of the imaginary number, it is himself a real number).

    Kind regards.

  • Calibration system as a solution of nonlinear equations

    Nice day

    The challenge of the day is to provide a calibration for a release of the accelerometer, expressed as a binary value.

    I have an accelerometer whose operating range can be set (±2g, ±4g ±8g).  The accelerometer itself then generates a binary value to 16-bit resolution.  Therefore, only 2 ^ 16 value (0-65535) represents an acceleration value of which depends on the lines we have.

    So we make the asumption that the response is linear, which allows us to claim:

    Acceleration = scale x value binary + Offset

    I have three axes of a value of data, accelerometer A, B and C.  If I hold the stationary accelerometer, the only thing that I should be reading is acceleration due to gravity, g.  It makes me of the relationship

    (A) ^ 2 + (B) ^ 2 + (C) ^ 2 = g ^ 2

    Since then, in any direction, the magnitude of the combination of all the three readings of the acceleration must be the gravitational acceleration (and that shouldn't change little matter which side you happen be pointing the accelerometer).

    What gives me, then, is a non-linear relationship of 6 variables (scale factors three and three shifts). I should be able to take six measures in an arbitrary orientation that will give me six output values of each had.  Then I should be able to get out the scale factors and offsets for each accelerometer, either in terms of g or with respect to which, in my opinion, g is.

    So, my question is how can I get Labview to do this?  I see that there is a tool to solve linear equations, but I don't see one appropriate for the non-linear case.  I'm also very comfortable believing that I'm just missing it :-)

    Thank you!

    Since the help file detail to the nD nonlinear system Solver.vi:

    Formula Variables VI analysis

    The formula analysis screws accept only the following variables:

    Note  These same variables to specify the description of the chain of the formula for the adjustment of non-linear curve VI.

    a, a0,..., a9

    b, b0,..., b9

    .

    .

    .

    z, z0,..., z9

    For variable and function names, only lower-case letters are allowed. Screw interpret case as errors.

    1. I found this by opening the Panel before the nonlinear Solver VI when executing your VI. The error information said that there was a problem with the formula.

    2. I replaced the Scale__ and Offset__ variables with a0, a1, b0, b1, c0 and c1 in tables X and f (x).

    3. I have expanded the values start and end - 10 and 10.

    This seems to work much better. At least it runs.

    Lynn

  • Best Poly Fit Coefficients do not match the best Poly Fit 2

    Hello

    I have dataset with 9 points and want to adapt or to solve linear equations with coefficient 9. The model - equation is then

    Z = a0 + a1 * x + y * a2 + a3 * x ^ 2 + a4 * x * y * + a5 * y ^ 2 + a6 * x ^ 7 * x + 2 * y * y ^ 2 + a8 * x ^ 2 * y ^ 2; coefficient 9 total EQ.

    When I create the matrix H and send data to 'General linear Fit' it returns coeffcients and the best fit. Better adapt works well but I don't know how to interpret a coeficients.

    All the math of it works well when the function is second order polynom, for example, when there coefficient a0 to a5.

    Thanks in advance.

    Sasa

    You're right, it works!

    I fix error of 11 to 1, but also the algorithm must be "acquired" and then match.

    Thank you!!!

Maybe you are looking for