 
     matrix_iterator forwardMatrix;
     matrix_iterator backwardMatrix;
-    double *scalingFactors;
+    matrix_iterator scalingFactors;
 
     double sM, sI, bM, bI;
 

        const uint32 matrix_offset = matrix_index % baq_stride<system>::stride;
        const uint32 matrix_base = matrix_index - matrix_offset;

        // set up matrix and scaling factor pointers
        forwardMatrix = matrix_iterator(&ctx.baq.forward[matrix_base + matrix_offset]);
        backwardMatrix = matrix_iterator(&ctx.baq.backward[matrix_base + matrix_offset]);
        scalingFactors = &ctx.baq.scaling[scaling_index];

        // get the windows for the current read
        const auto& hmm_reference_window = ctx.baq.hmm_reference_windows[read_index];

    {
        const CRQ_index idx = batch.crq_index(read_index);
        return idx.read_len + 2;
    }
};

template <target_system system>
struct compute_hmm_scaling_factor_size_strided : public lambda<system>
{
    LAMBDA_INHERIT;

    typename vector<system, uint32>::const_view active_read_list;
    typename vector<system, uint32>::view scaling_index_output;

    compute_hmm_scaling_factor_size_strided(typename firepony_context<system>::view ctx,
                                            const typename alignment_batch_device<system>::const_view batch,
                                            typename vector<system, uint32>::const_view active_read_list,
                                            typename vector<system, uint32>::view scaling_index_output)
        : lambda<system>(ctx, batch),
          active_read_list(active_read_list),
          scaling_index_output(scaling_index_output)
    { }

    CUDA_HOST_DEVICE void operator() (const uint32 index)
    {
        uint32 ret = 0;

        // smear the max scaling factor size across the thread group so we can stride it later on
        constexpr uint32 stride = baq_stride<system>::stride;
        const uint32 start_range = index - (index % stride);
        const uint32 end_range = start_range + stride;

        for(uint32 i = start_range; i < end_range; i++)
        {
            if (i < active_read_list.size())
            {
                const uint32 read_index = active_read_list[i];
                const CRQ_index idx = batch.crq_index(read_index);
                const uint32 size = idx.read_len + 2;
                ret = max(ret, size);
            }
        }

        scaling_index_output[index] = ret;
    }
};

