Apply mesh transformations to primitive_uv_sphere_add() How can I apply mesh transformations using the Blender's mathutils 3D transformation matrix to a sphere formed using bpy.ops.mesh.primitive_uv_sphere_add()

I am successfully able to construct a 3D transformtaion matrix using mathutils.Matrix.Rotation matrix and mathutils.Matrix.Translation matrix and apply the transform() operation on a mesh created manually using me = bpy.data.meshes.new() and passing it the vertices and faces/edges using me.from_pydata(verts, edges, faces). However, I would like to use the same transformation matrix to apply the corresponding transformations to a sphere.

Can someone point out a way to do the above; or suggest some workaround for the same?
This can be achieved by getting the mesh of the object and multiplying the transformation matrix to each vertex. (Possibly there is a convenience function for that).

import bpy
from bpy import context
import mathutils
from mathutils import Vector,Quaternion
import math

obj = bpy.data.objects["Cube"]  # particular object by name
#obj = bpy.context.scene.objects.active # active object

# setup whatever matrix
mx = mathutils.Matrix.Rotation(math.radians(15.0), 4, 'X')

mesh = obj.data
for vert in mesh.vertices:
    vert.co = mx * vert.co