added code to calculate kernel mat without a loop
added code to calculate kernel mat without a loop