LSM303 smoothing compass headings

I am trying to smooth my headings coming from my LSM303 sensor. I get get get the tilt compensated values, but I just want to smooth them. Please help!

trying something like this...

#include <Wire.h>
#include <LSM303.h>


LSM303 compass;

// Define the number of samples to keep track of.  The higher the number,
// the more the readings will be smoothed, but the slower the output will
// respond to the input.  Using a constant rather than a normal variable lets
// use this value to determine the size of the readings array.
const int numReadings = 10;

int readings[numReadings];      // the readings from the analog input
int index = 0;                  // the index of the current reading
int total = 0;                  // the running total
int average = 0;                // the average

int inputPin = Compass.heading;
void setup() {
  Serial.begin(9600);
  
  // initialize all the readings to 0:
   for (int thisReading = 0; thisReading < numReadings; thisReading++)
    readings[thisReading] = 0; 
    
  Wire.begin();
  compass.init();
  compass.enableDefault();
  
  // Calibration values. Use the Calibrate example program to get the values for
  // your compass.
  compass.m_min.x = -646; compass.m_min.y = -689; compass.m_min.z = -454;
  compass.m_max.x = +338; compass.m_max.y = +450; compass.m_max.z =+586;
}

void loop() {
  compass.read();
  int heading = compass.heading((LSM303::vector){0,-1,0});
  
    // subtract the last reading:
  total= total - readings[index];         
  // read from the sensor:  
  readings[index] = analogRead(inputPin); 
  // add the reading to the total:
  total= total + readings[index];       
  // advance to the next position in the array:  
  index = index + 1;                    

  // if we're at the end of the array...
  if (index >= numReadings)              
    // ...wrap around to the beginning: 
    index = 0;                           

  // calculate the average:
  average = total / numReadings;   
  
  Serial.println(average);
  delay(100);
}

using these links as a guide...

One way of smoothing that will remove 'noise' in a signal is to only add a proprotion (one third, one quarter, whatever makes sense) of the difference between the 'current' smoothed value and the current read value. Fast moving changes get smoothed out and the number will converge slowly.

The proportion you use will depend on what you see as noise and how much you can tolerate.

sketch_jan20a.ino: In function 'void loop()':
sketch_jan20a:118: error: cannot convert 'int*' to 'float*' for argument '1' to 'void Smoothing(float*, float*)'
sketch_jan20a:119: error: cannot convert 'int*' to 'float*' for argument '1' to 'void Smoothing(float*, float*)'
sketch_jan20a:120: error: cannot convert 'int*' to 'float*' for argument '1' to 'void Smoothing(float*, float*)'
sketch_jan20a.ino: In function 'void IMUinit()':
sketch_jan20a:154: error: 'LSM303_CTRL_REG1_A' was not declared in this scope
sketch_jan20a:155: error: 'LSM303_CTRL_REG4_A' was not declared in this scope
sketch_jan20a:157: error: 'LSM303_CRA_REG_M' was not declared in this scope
sketch_jan20a:158: error: 'LSM303_CRB_REG_M' was not declared in this scope
sketch_jan20a:159: error: 'LSM303_MR_REG_M' was not declared in this scope
sketch_jan20a:168: error: cannot convert 'int*' to 'float*' for argument '1' to 'void Smoothing(float*, float*)'
sketch_jan20a:169: error: cannot convert 'int*' to 'float*' for argument '1' to 'void Smoothing(float*, float*)'
sketch_jan20a:170: error: cannot convert 'int*' to 'float*' for argument '1' to 'void Smoothing(float*, float*)'
sketch_jan20a:179: error: cannot convert 'int*' to 'float*' for argument '1' to 'void Smoothing(float*, float*)'
sketch_jan20a:180: error: cannot convert 'int*' to 'float*' for argument '1' to 'void Smoothing(float*, float*)'
sketch_jan20a:181: error: cannot convert 'int*' to 'float*' for argument '1' to 'void Smoothing(float*, float*)'
I add the library but it give error?

Added which library ?
It looks like you screwed up the library that you already had.