class_docstr: Apply function to a matrix elementwise without evaluating.
  
  Examples
  ========
  
  It can be created by calling ``.applyfunc(<function>)`` on a matrix
  expression:
  
  >>> from sympy import MatrixSymbol
  >>> from sympy.matrices.expressions.applyfunc import ElementwiseApplyFunction
  >>> from sympy import exp
  >>> X = MatrixSymbol("X", 3, 3)
  >>> X.applyfunc(exp)
  Lambda(_d, exp(_d)).(X)
  
  Otherwise using the class constructor:
  
  >>> from sympy import eye
  >>> expr = ElementwiseApplyFunction(exp, eye(3))
  >>> expr
  Lambda(_d, exp(_d)).(Matrix([
  [1, 0, 0],
  [0, 1, 0],
  [0, 0, 1]]))
  >>> expr.doit()
  Matrix([
  [E, 1, 1],
  [1, E, 1],
  [1, 1, E]])
  
  Notice the difference with the real mathematical functions:
  
  >>> exp(eye(3))
  Matrix([
  [E, 0, 0],
  [0, E, 0],
  [0, 0, E]])
class_docstr_tok: ["Apply","function","to","a","matrix","elementwise","without","evaluating",".","Examples","========","It","can","be","created","by","calling","``",".applyfunc","(","<","function",">",")","``","on","a","matrix","expression",":",">",">",">","from","sympy","import","MatrixSymbol",">",">",">","from","sympy.matrices.expressions.applyfunc","import","ElementwiseApplyFunction",">",">",">","from","sympy","import","exp",">",">",">","X","=","MatrixSymbol","(","``","X","''",",","3",",","3",")",">",">",">","X.applyfunc","(","exp",")","Lambda","(","_d",",","exp","(","_d",")",")",".","(","X",")","Otherwise","using","the","class","constructor",":",">",">",">","from","sympy","import","eye",">",">",">","expr","=","ElementwiseApplyFunction","(","exp",",","eye","(","3",")",")",">",">",">","expr","Lambda","(","_d",",","exp","(","_d",")",")",".","(","Matrix","(","[","[","1",",","0",",","0","]",",","[","0",",","1",",","0","]",",","[","0",",","0",",","1","]","]",")",")",">",">",">","expr.doit","(",")","Matrix","(","[","[","E",",","1",",","1","]",",","[","1",",","E",",","1","]",",","[","1",",","1",",","E","]","]",")","Notice","the","difference","with","the","real","mathematical","functions",":",">",">",">","exp","(","eye","(","3",")",")","Matrix","(","[","[","E",",","0",",","0","]",",","[","0",",","E",",","0","]",",","[","0",",","0",",","E","]","]",")"]
code: def _eval_derivative_matrix_lines(self, x):
      from sympy.matrices.expressions.special import Identity
      from sympy.tensor.array.expressions.array_expressions import (
          ArrayContraction,
      )
      from sympy.tensor.array.expressions.array_expressions import (
          ArrayDiagonal,
      )
      from sympy.tensor.array.expressions.array_expressions import (
          ArrayTensorProduct,
      )
  
      fdiff = self._get_function_fdiff()
      lr = self.expr._eval_derivative_matrix_lines(x)
      ewdiff = ElementwiseApplyFunction(fdiff, self.expr)
      if 1 in x.shape:
          # Vector:
          iscolumn = self.shape[1] == 1
          for i in lr:
              if iscolumn:
                  ptr1 = i.first_pointer
                  ptr2 = Identity(self.shape[1])
              else:
                  ptr1 = Identity(self.shape[0])
                  ptr2 = i.second_pointer
  
              subexpr = ExprBuilder(
                  ArrayDiagonal,
                  [
                      ExprBuilder(
                          ArrayTensorProduct,
                          [
                              ewdiff,
                              ptr1,
                              ptr2,
                          ],
                      ),
                      (0, 2) if iscolumn else (1, 4),
                  ],
                  validator=ArrayDiagonal._validate,
              )
              i._lines = [subexpr]
              i._first_pointer_parent = subexpr.args[0].args
              i._first_pointer_index = 1
              i._second_pointer_parent = subexpr.args[0].args
              i._second_pointer_index = 2
      else:
          # Matrix case:
          for i in lr:
              ptr1 = i.first_pointer
              ptr2 = i.second_pointer
              newptr1 = Identity(ptr1.shape[1])
              newptr2 = Identity(ptr2.shape[1])
              subexpr = ExprBuilder(
                  ArrayContraction,
                  [
                      ExprBuilder(
                          ArrayTensorProduct,
                          [ptr1, newptr1, ewdiff, ptr2, newptr2],
                      ),
                      (1, 2, 4),
                      (5, 7, 8),
                  ],
                  validator=ArrayContraction._validate,
              )
              i._first_pointer_parent = subexpr.args[0].args
              i._first_pointer_index = 1
              i._second_pointer_parent = subexpr.args[0].args
              i._second_pointer_index = 4
              i._lines = [subexpr]
      return lr
  
file_path: sympy/sympy/matrices/expressions/applyfunc.py
imports: from sympy.core.expr import ExprBuilder
  from sympy.core.function import Function, FunctionClass, Lambda
  from sympy.core.symbol import Dummy
  from sympy.core.sympify import sympify, _sympify
  from sympy.matrices.expressions import MatrixExpr
  from sympy.matrices.matrixbase import MatrixBase
label_desc: Use image node_id 9 for calling the ElementwiseApplyFunction obj's underlying member method code with example usage: obj._eval_derivative_matrix_lines(x) and returns: lr