Permalink
Switch branches/tags
Nothing to show
Find file Copy path
a16921b Jan 17, 2018
1 contributor

Users who have contributed to this file

178 lines (160 sloc) 7.34 KB

 

 

 

 

 

(C++) Math

 

Code snippets to solve mathematical problems.

 

  1. Add two to all elements in a std::vector, AddTwo
  2. AddTwo, add two to all elements in a std::vector
  3. Calculate a factorial
  4. Calculate an angle between two coordinats
  5. Calculate the distance between two coordinats
  6. Calculate the greatest common divisor
  7. Calculate the impulses after a perfect elastic collision, DoPerfectElasticCollision
  8. Calculate the product of std::vector elements, Product
  9. Calculate the product of all non-zero positive values in a std::vector, ProductNonZeroPositives
  10. Calculate X to the power of Y for integers, IntPower
  11. Convolution, perform a convolution on an image, DoFilterOperation
  12. Count the number of non-zero positive values in a std::vector, CountNonZeroPositives
  13. CountNonZeroPositives, count the number of non-zero positive values in a std::vector
  14. Cryptography algorithm (a very simple one)
  15. DivideTerms, divide two product term sets (for example {1,2,3,4}/{1,2,3} = 4)
  16. Divide two product term sets, DivideTerms (for example {1,2,3,4}/{1,2,3} = 4)
  17. DoFilterOperation, perform a convolution on an image
  18. DoFilterOperation, perform a filter operation on an image
  19. DoPerfectElasticCollision, calculate the impulses after a perfect elastic collision
  20. Factorial: Calculate a factorial
  21. Filter operation, perform a filter operation on an image, DoFilterOperation
  22. FindEquilibrium: Finding an equilibrium or a cycle (uses the logistic growth equation)
  23. Finding a sum for any combination of values (a.k.a. The Combinator)
  24. Finding an equilibrium or a cycle (uses the logistic growth equation)
  25. Fmod: modulus on floating point numbers
  26. Gcd: Calculate the greatest common divisor
  27. Get the cumulative std::vector of a std::vector, GetCumulativeHistogram
  28. Get the mean and standard deviation
  29. Get the mean value of all elements in a container, GetMean
  30. Get the mean value of all elements in a container, GetMean
  31. Get the product terms of a factorial, GetFactorialTerms
  32. Get the standard deviation of the values in a container, GetStdDev
  33. GetAngle: Calculate an angle between two coordinats
  34. GetCumulativeHistogram, get the cumulative std::vector of a std::vector
  35. GetDistance: Calculate the distance between two coordinats
  36. GetFactorialTerms, get the product terms of a factorial
  37. GetMean, get the mean value of all elements in a container
  38. GetStdDev, get the standard deviation of the values in a container
  39. GetSum, get the sum of all elements in a container
  40. GetSumProperDivisors, get the sum of all proper divisors of an integer
  41. Halve, replace all values in std::vector by their halves
  42. IntPower, calculate X to the power of Y for integers
  43. IsPerfectNumber, determines if a number is a perfect number
  44. IsPrime, is a number prime?
  45. MakeAbs, replace all values in a std::vector by their absolutes
  46. MakeSquare, square all values in a std::vector
  47. Maze code snippets
  48. MeanAndStdDev: Get the mean and standard deviation
  49. Modulus on floating point numbers
  50. Normal Distribution code snippets
  51. Perfect elastic collision
  52. Perform a convolution on an image, DoFilterOperation
  53. Perform a filter operation on an image, DoFilterOperation
  54. Prime, IsPrime, is a number prime?
  55. Prime, PrimeExpert, to determine whether a number is prime quicker
  56. PrimeExpert, to determine whether a number is prime quicker
  57. Product, calculate the product of std::vector elements
  58. ProductNonZeroPositives, calculate the product of all non-zero positive values in a std::vector
  59. Random number code snippets
  60. Reciprocal, replace all values in a std::vector by their reciprocals
  61. Replace all values in a std::vector by their absolutes, MakeAbs
  62. Replace all values in std::vector by their halves, Halve
  63. Replace all values in a std::vector by their reciprocals, Reciprocal
  64. Replace all negative values in a std::vector by zeroes, ReplaceNegativeByZero
  65. Replace all zeroes in a std::vector by a ones, ReplaceZeroByOne
  66. Replace identical product terms by 1, StripeAwayTerms (for example {1,2,3,4} and {1,2,3} become {1,1,1,4} and {1,1,1})
  67. ReplaceNegativeByZero, replace all negative values in a std::vector by zeroes
  68. ReplaceZeroByOne, replace all zeroes in a std::vector by ones
  69. Rescale a 2D std::vector from a certain range to a new range, Rescale
  70. Rescale a double from a certain range to a new range, Rescale
  71. Rescale, rescale a 2D std::vector from a certain range to a new range
  72. Rescale, rescale a double from a certain range to a new range
  73. Round a double to an integer, RoundOff
  74. RoundOff, round a double to an integer
  75. Statistics code snippets
  76. Solve a quadratic equation, SolveQuadratic
  77. SolveQuadratic, solve a quadratic equation
  78. Square all values in a std::vector, MakeSquare
  79. StripeAwayTerms, replace identical product terms by 1 (for example {1,2,3,4} and {1,2,3} become {1,1,1,4} and {1,1,1})
  80. Sum all positive values in a std::vector, SumPositives
  81. SumPositives, sum all positive values in a std::vector
  82. The Combinator: Finding a sum for any combination of values
  83. Triple, triple all values in a std::vector
  84. Triple all values in a std::vector, Triple