My experience on my daily works... helping others ease each other

Coders never die. Welcome to the CODER side

Enjoy your meal .. focus on your dream .. Do the thing you love .. and love the thing you do

Be the fire to show the light not to burn the life

Be the KHALIFAH .. set the right path .. May the code always work fine .. for you to sleep with no nightmare :)

Long live developer

Breakfast with C food, Drink Java coffee, Lunch with PHP, Dinner with DB, Supper with HTML and CSS, Sleep with Javascript

Come back to where you belong

No matter how far you go, how high you climb, how deep you fall, how long you travel, how fast you move.. Please remember that everything happen for a reason. So do the program you code :)

Looking far ahead

A leader will look far ahead but walk the same path with his people

Saturday, June 13, 2020

Caching an Inverse of a Matrix Using R

Caching an Inverse of a Matrix Using R 

Matrix inversion is usually a costly computation and there may be some benefit to caching the inverse of a matrix rather than computing it repeatedly.

This is an example code to cache an inverse of a matrix which then called if:

1. The new matrix computation similar to the previous matrix
2. Matrix is invertible — Read Invertible Matrix
3. The structure and content of the new matrix is equal to previous

The program consists of two functions

  1. A function to cache the matrix and the inverse. It is similar to getter and setter in many programming languages like Java and C.
  2. A function which will be call for the computational process of the matrix

Here are parts of the code:

Setting the matrix
Setting the inverse matrix
Verification on the matrix
Setting the new inverse

Complete source code is reachable at

If you like the post, do buy me a coffee please :)

Buy Me A Coffee

About Me

An IT by profession, a beginner in photography

Nurul Haszeli Ahmad

Experience in software/system development and research since 1999

My Interest - Information Security (Software Security, Program Analysis, and Web-based application)

My skill - Flex, Java, PHP, Scripting (ActionScript, TypeScript, JS,e tc), All kind of Databases, Web application, LabVIEW and little-bit in C/C++

Academic Profile: Haszeli

Buy me a coffeeBuy me a coffee

Blog Archive