Giter Site home page Giter Site logo

Comments (4)

DanielMartensson avatar DanielMartensson commented on May 30, 2024 1

Can you write out what the value is at this line

if (fabsf(LU[row * P[i] + i]) < FLT_EPSILON)

When lup.c file returns 0, then the inv.c returns 0 as well.

Edit:

I did a quick check. I found the issue

/*
 ============================================================================
 Name        : inv.c
 Author      : Daniel Mårtensson
 Version     : 1.0
 Copyright   : MIT
 Description : Turn A into inverse A^(-1)
 ============================================================================
 */

#include "CControl/Headers/Functions.h"

int main() {

	// Matrix A
	float A[2*2] = {1, 1, 1, 1};

	clock_t start, end;
	float cpu_time_used;
	start = clock();
	int status = inv(A, 2);
	printf("Status on matrix A(1 == success, 0 == fail): %d\n", status);
	end = clock();
	cpu_time_used = ((float) (end - start)) / CLOCKS_PER_SEC;
	printf("\nTotal speed  was %f\n", cpu_time_used);

	// Print A
	printf("A^(-1)\n");
	print(A, 2, 2);

	return EXIT_SUCCESS;
}

Output:

Status on matrix A(1 == success, 0 == fail): 1

Total speed  was 0.000000
A^(-1)
1.#INF00000000000000	-1.#INF00000000000000	
-1.#INF00000000000000	1.#INF00000000000000	

The issue is here:
Question: Can you be so kind to do an if-statement and check if we are dividing with 0 ? If we are dividing with zero, then the static function should return uint8_t or bool as 0 or false. As a check only. Can you do this? Send me then a pull request?

x[i] = x[i] / LU[row * P[i] + i];

Edit:

I have fixed the issue.
Please re-open the issue if the issue still occurs.

from ccontrol.

ooaj avatar ooaj commented on May 30, 2024

Aha. Great! Thanks @DanielMartensson. Works perfectly now.

from ccontrol.

DanielMartensson avatar DanielMartensson commented on May 30, 2024

Aha. Great! Thanks @DanielMartensson. Works perfectly now.

Thank you @ooaj for finding this issue.
If you want, you could help me implement a Kernel Density Estimation algorithm. It's very easy.

Here is the formula:
image

K is the gaussian propability density function.

https://en.wikipedia.org/wiki/Kernel_density_estimation#Definition

The theory: See between 0:0 to 2:00 https://www.youtube.com/watch?v=DCgPRaIDYXA&t=1s&ab_channel=KimberlyFessel

Assume that you have a mesurement float my_measurement[100] and you want to find the correct value, because it's a nonlinear measurement. If you plot float my_measurement[100] you can see two gaussian curves, but which one should you select? Just use KDE algorithm as above.

Can you do that?

from ccontrol.

ooaj avatar ooaj commented on May 30, 2024

Sure. I can try to implement it. I have a very busy weekend, so if that's not a problem I can start working on it on Monday. I imagine you are going to be using it for your Particle Filter, right?

from ccontrol.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.